added bootstrap theme

This commit is contained in:
2025-03-23 21:02:44 +01:00
parent 96c23c62d1
commit f50f6fc7cd
4 changed files with 82 additions and 79 deletions

View File

@ -9,7 +9,8 @@ from isotopapp.models import Isotope
# Create your views here.
def home(request):
return render(request, 'home.html')
isotopes = [i for i in Isotope.objects.all() if (i.gamma != 0 or i.stable)]
return render(request, 'home.html', {'isotopes': [[f"{i.n_nucleons}{i.symbol}", mark_safe(f"<sup>{i.n_nucleons}</sup>{i.symbol}")] for i in isotopes]})
def extract_isotope_parts(isotope_str):
"""Extracts the number and element from an isotope string (e.g., '23Na')."""
@ -31,13 +32,12 @@ def isotope_info(isotope, field):
f"{f_larmor:.3f}",
spin,
f"{isotope.natural_abundance:.1f}",
f"{isotope.gamma*1e6:.5e}"]
f"{isotope.gamma:.5f}"]
def result(request):
n1, element1 = extract_isotope_parts(request.GET.get('isotope1'))
isotope1 = Isotope.objects.filter(symbol=element1, n_nucleons=n1).get()
freq = float(request.GET.get('freq'))
field_T = freq / isotope1.gamma
@ -54,7 +54,7 @@ def result(request):
f_Larmor = field_T*isotope.gamma
if abs(f_Larmor - freq) <= freq_range:
close_isotopes.append(isotope_info(isotope, field_T))
ans = sorted(close_isotopes, key=lambda x: x[3])
ans = sorted(close_isotopes, key=lambda x: -float(x[3]))
elif request.GET.get('calculate') == "":
sample_diameter = 5e-3