From 018618f944eb3ddde98867cf99f50be930ccefb3 Mon Sep 17 00:00:00 2001 From: Paul Kienzle Date: Thu, 3 Mar 2022 15:55:28 -0500 Subject: [PATCH] Add mass fraction table. Refs #14. --- activation/index.html | 44 +++++++++++++++++++++++++++++++++++++++---- cgi-bin/nact.py | 5 +++-- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/activation/index.html b/activation/index.html index 076b4db..84c9715 100644 --- a/activation/index.html +++ b/activation/index.html @@ -182,6 +182,7 @@ } ELEMENTS = {"n": 0, "H": 1, "He": 2, "Li": 3, "Be": 4, "B": 5, "C": 6, "N": 7, "O": 8, "F": 9, "Ne": 10, "Na": 11, "Mg": 12, "Al": 13, "Si": 14, "P": 15, "S": 16, "Cl": 17, "Ar": 18, "K": 19, "Ca": 20, "Sc": 21, "Ti": 22, "V": 23, "Cr": 24, "Mn": 25, "Fe": 26, "Co": 27, "Ni": 28, "Cu": 29, "Zn": 30, "Ga": 31, "Ge": 32, "As": 33, "Se": 34, "Br": 35, "Kr": 36, "Rb": 37, "Sr": 38, "Y": 39, "Zr": 40, "Nb": 41, "Mo": 42, "Tc": 43, "Ru": 44, "Rh": 45, "Pd": 46, "Ag": 47, "Cd": 48, "In": 49, "Sn": 50, "Sb": 51, "Te": 52, "I": 53, "Xe": 54, "Cs": 55, "Ba": 56, "La": 57, "Ce": 58, "Pr": 59, "Nd": 60, "Pm": 61, "Sm": 62, "Eu": 63, "Gd": 64, "Tb": 65, "Dy": 66, "Ho": 67, "Er": 68, "Tm": 69, "Yb": 70, "Lu": 71, "Hf": 72, "Ta": 73, "W": 74, "Re": 75, "Os": 76, "Ir": 77, "Pt": 78, "Au": 79, "Hg": 80, "Tl": 81, "Pb": 82, "Bi": 83, "Po": 84, "At": 85, "Rn": 86, "Fr": 87, "Ra": 88, "Ac": 89, "Th": 90, "Pa": 91, "U": 92, "Np": 93, "Pu": 94, "Am": 95, "Cm": 96, "Bk": 97, "Cf": 98, "Es": 99, "Fm": 100, "Md": 101, "No": 102, "Lr": 103, "Rf": 104, "Db": 105, "Sg": 106, "Bh": 107, "Hs": 108, "Mt": 109, "Ds": 110, "Rg": 111, "Cn": 112, "Nh": 113, "Fl": 114, "Mc": 115, "Lv": 116, "Ts": 117, "Og": 118}; + //ACTIVE_BUTTON = "material"; ACTIVE_BUTTON = "activation"; // Parse environment variables "index.html?cutoff=...&abundance=..." function getURLParameter(name) { @@ -222,9 +223,25 @@ var element = a[0], isotope = a[1]; return ELEMENTS[element] + parseInt(isotope)/1000; } + function parse_element(s) { + var a = s.split("-"); + var element, isotope; + if (a.length > 1) { + element = a[1], isotope = a[0]; + } else { + element = a[0], isotope = 0; + } + return ELEMENTS[element] + parseInt(isotope)/1000; + } + $.tablesorter.addParser({ + id: 'element', + is: function (s) { return /^ *([0-9]+-)?[A-Z][a-z]? *$/.test(s); }, + format: function (s) { return parse_element(s); }, + type: 'numeric' + }); $.tablesorter.addParser({ id: 'isotope', - is: function (s) { return /^ *[A-Z][a-z]?-[0-9]+[sm+]* *$/.test(s); }, + is: function (s) { return /^ *[A-Z][a-z]?-[0-9]+[stm+]* *$/.test(s); }, format: function (s) { return parse_isotope(s); }, type: 'numeric' }); @@ -274,6 +291,7 @@ // can't do anything. $('.container').removeClass("disabled"); $('#id_chemical_formula').removeAttr("disabled"); + //$('#id_submit_frac').removeAttr("disabled"); $('#id_submit_scat').removeAttr("disabled"); $('#id_submit_act').removeAttr("disabled"); $('a').each(function(){ this.tabIndex = -1; }); @@ -290,11 +308,14 @@ ACTIVE_BUTTON = "scattering"; } else if (panel == "activation-panel") { ACTIVE_BUTTON = "activation"; + //} else if (panel == "material-panel") { + // ACTIVE_BUTTON = "material"; } } ); //$("#id-activationForm").submit(submit_query); $("#id-activationForm").submit(function(event) {event.preventDefault();}); + //$('#id_submit_frac').click(function() { submit_query('material'); }); $('#id_submit_scat').click(function() { submit_query('scattering'); }); $('#id_submit_act').click(function() { submit_query('activation'); }); } @@ -384,11 +405,11 @@ activity_button = ''; } //add headers to table - content += '\n \n'; + content += '
\n \n'; content += ' \n'; content += ' '; for (var i in data.headers) { - content += ''; + content += ''; } content += '\n \n \n' for (var i in data.rows) { @@ -409,6 +430,14 @@ content += '\n \n
'+activity_header+activity_button+'
' + data.headers[i] + '' + data.headers[i] + '
\n'; return content; } + function fraction_table(massfrac) { + var content = ' \n'; + for (var element in massfrac) { + content += ' \n'; + } + content += '
element/isotopemass fraction
'+element+''+massfrac[element]+'
'; + return content; + } function show_error(error_html) { var content = '

\n'; content += error_html; @@ -556,6 +585,9 @@ + '×10-62)

\n'; } } + + // Add the mass fraction table to the scattering summary. + content += fraction_table(sample.mass_fractions); } @@ -563,7 +595,10 @@ content += '
\n'; $(content).prependTo('div[id=results]'); //add to the dom - $("table").tablesorter({sortList: [[8,1]]}); + // Sort activations in reverse order by target time (column 8, descending) + $(".activation_table").tablesorter({sortList: [[8,1]]}); + // Sort materials in reverse order by mass fraction (column 1, descending) + $(".material_table").tablesorter({sortList: [[1,1]]}); } // Dynamic help support. Clicking an input field jumps to the @@ -621,6 +656,7 @@

Material

+
diff --git a/cgi-bin/nact.py b/cgi-bin/nact.py index 8a34af0..182265d 100755 --- a/cgi-bin/nact.py +++ b/cgi-bin/nact.py @@ -261,8 +261,8 @@ def cgi_call(): # Parse inputs errors = {} calculate = form.getfirst('calculate', 'all') - if calculate not in ('scattering', 'activation', 'all'): - errors['calculate'] = "calculate should be one of 'scattering', 'activation' or 'all'" + if calculate not in ('scattering', 'activation', 'material', 'all'): + errors['calculate'] = "calculate should be one of {scattering, activation, material, all}." try: sample = form.getfirst('sample') chem = formula(sample) @@ -393,6 +393,7 @@ def cgi_call(): 'density': chem.density, 'thickness': thickness, 'natural_density': chem.natural_density, + 'mass_fractions': {str(k): v for k, v in chem.mass_fraction.items()}, } # Run calculations