add column with rel. sensitivity
This commit is contained in:
parent
e6a841e09a
commit
b7a7edfa7b
@ -22,6 +22,7 @@
|
||||
<th scope="col">Spin</th>
|
||||
<th scope="col">Nat. ab. in %</th>
|
||||
<th scope="col">γ in MHz/T</th>
|
||||
<th scope="col">Sens. in %(<sup>1</sup>H)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -39,13 +40,18 @@
|
||||
{{ div| safe }}
|
||||
|
||||
<div>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/latest.js"
|
||||
integrity="sha512-nUTIGJLS9aRMjQaRwpCiC+0Y2RzgW4sufFhFgyjHgn15DXLSfoVUaEa83CsNe2FSJpLXtfgdVfgL7a0lrbcBWA=="
|
||||
crossorigin="anonymous"
|
||||
referrerpolicy="no-referrer">
|
||||
</script>
|
||||
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-3.7.1.min.js"></script>
|
||||
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.7.1.min.js"></script>
|
||||
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.7.1.min.js"></script>
|
||||
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-api-3.7.1.min.js"></script>
|
||||
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.7.1.min.js"></script>
|
||||
|
||||
{{ script| safe }}
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -5,7 +5,7 @@ from django.shortcuts import render
|
||||
from django.utils.safestring import mark_safe
|
||||
import re
|
||||
|
||||
from bokeh.plotting import figure as bokehfig
|
||||
from bokeh.plotting import figure
|
||||
from bokeh.embed import components
|
||||
from bokeh.models import Label, Node, MathML
|
||||
|
||||
@ -36,8 +36,21 @@ def isotope_info(isotope, field):
|
||||
isotope.name.capitalize(),
|
||||
f"{f_larmor:.3f}",
|
||||
spin,
|
||||
f"{isotope.natural_abundance:.1f}",
|
||||
f"{isotope.gamma:.5f}"]
|
||||
f"{isotope.natural_abundance:.3f}",
|
||||
f"{isotope.gamma:.5f}",
|
||||
f"{relative_sensitivity(isotope):.4f}"]
|
||||
|
||||
def relative_sensitivity(iso):
|
||||
riso = Isotope.objects.filter(symbol="H", n_nucleons="1").get()
|
||||
i1 = riso.spin_quantum_number
|
||||
g1 = riso.gamma
|
||||
ab1 = riso.natural_abundance
|
||||
i2 = float(iso.spin_quantum_number)
|
||||
g2 = float(iso.gamma)
|
||||
ab2 = float(iso.natural_abundance)
|
||||
rel_sens = i2*(i2+1)*g2**3*ab2 / (i1*(i1+1)*g1**3*ab1)
|
||||
print(rel_sens)
|
||||
return rel_sens*100
|
||||
|
||||
def result(request):
|
||||
n1, element1 = extract_isotope_parts(request.GET.get('isotope1'))
|
||||
@ -52,7 +65,7 @@ def result(request):
|
||||
|
||||
print(request.GET)
|
||||
if request.GET.get('range_search') == "":
|
||||
close_isotopes = [isotope_info(isotope1, field_T)]
|
||||
close_isotopes = []
|
||||
freq_range = float(request.GET.get('freq_range'))
|
||||
Isotope.objects.filter()
|
||||
# calculate the frequency for all isotopes and compile a list of close by isotopes
|
||||
@ -63,12 +76,15 @@ def result(request):
|
||||
if abs(f_Larmor - freq) <= freq_range:
|
||||
close_isotopes.append(isotope_info(isotope, field_T))
|
||||
ans = sorted(close_isotopes, key=lambda x: -float(x[3]))
|
||||
div = f"Field B<sub>0</sub>: {field_T:.3f} T"
|
||||
script = ""
|
||||
|
||||
elif request.GET.get('gradient_search') == "":
|
||||
sample_diameter = 5e-3
|
||||
gradient = float(request.GET.get('gradient'))
|
||||
# create a plot (bokeh)
|
||||
plot = bokehfig(outer_width=400, outer_height=400, match_aspect=True)
|
||||
|
||||
plot = figure(outer_width=400, outer_height=400, match_aspect=True)
|
||||
plot.ellipse(x=[0], y=[0], width=5, height=5, color="#D5D9FF", alpha=0.8, line_width=1, line_color="black")
|
||||
plot.ellipse(x=[0], y= [2.5], width=5, height=5, color="#D5D9FF", alpha=0.4, line_width=1, line_color="black")
|
||||
plot.ellipse(x=[0], y=[-2.5], width=5, height=5, color="#D5D9FF", alpha=0.4, line_width=1, line_color="black")
|
||||
@ -83,17 +99,8 @@ def result(request):
|
||||
i_info = isotope_info(isotope, field_T)
|
||||
#i_info[3] = f"{z*1e3:.1f} mm"
|
||||
close_isotopes.append(i_info)
|
||||
mathml = f"""
|
||||
<math>
|
||||
<msup>
|
||||
{isotope.n_nucleons}
|
||||
</msup>
|
||||
{isotope.symbol}
|
||||
</math>
|
||||
"""
|
||||
plot.rect(x=[0], y=[z*1e3], width=5, height=0.2, color="black", alpha=0.6)
|
||||
label = Label(x=2.6, y=z*1e3, text=f"{isotope.n_nucleons}{isotope.symbol}", text_baseline="middle", text_align="left", text_font_size="16pt")
|
||||
#label = Label(x=2.6, y=z*1e3, text=MathML(mathml), text_baseline="middle", text_align="left", text_font_size="16pt")
|
||||
plot.add_layout(label)
|
||||
|
||||
frame_left = Node(target="frame", symbol="left", offset=5)
|
||||
@ -102,10 +109,10 @@ def result(request):
|
||||
x=frame_left,
|
||||
y=frame_bottom,
|
||||
anchor="bottom_left",
|
||||
#text=MathML(text=f"<math><msup>{isotope1.n_nucleons}</msup>{isotope1.symbol}: {freq:.1f} MHz\ng={gradient:.1f} T/m\n5 mm sample dia.</math>"),
|
||||
#text=MathML(text=f"<math><sup>{isotope1.n_nucleons}</msup>{isotope1.symbol}: {freq:.1f} MHz\ng={gradient:.1f} T/m\n5 mm sample dia.</math>"),
|
||||
text=f"{isotope1.n_nucleons}{isotope1.symbol}: {freq:.1f} MHz\ng={gradient:.1f} T/m\n5 mm sample dia.",
|
||||
#text=MathML("<math>tewt</math>"),
|
||||
padding=10,
|
||||
padding=5,
|
||||
border_radius=5,
|
||||
border_line_color="black", background_fill_color="white",
|
||||
)
|
||||
@ -119,7 +126,9 @@ def result(request):
|
||||
n2, element2 = extract_isotope_parts(request.GET.get('isotope2'))
|
||||
isotope2 = Isotope.objects.filter(symbol=element2, n_nucleons=n2).get()
|
||||
#isotope_info(isotope2, field_T)
|
||||
ans = [isotope_info(isotope2, field_T)]
|
||||
ans = [isotope_info(isotope2, field_T), isotope_info(isotope1, field_T) ]
|
||||
div = f"Field B<sub>0</sub>: {field_T:.3f} T"
|
||||
script = ""
|
||||
else:
|
||||
ans = []
|
||||
return render(request, 'result.html', {'ans': ans, 'script': script, 'div': div})
|
||||
|
Loading…
x
Reference in New Issue
Block a user