added copy Ex and add known states

This commit is contained in:
Ryan@fsunuc 2023-01-16 19:26:02 -05:00
parent ae56a9aa74
commit 56131d662e
5 changed files with 169 additions and 15 deletions

View File

@ -47,8 +47,8 @@ try :
print("<br> A : %3d, Z : %3d, N : %3d" % (Z+N, Z, N)) print("<br> A : %3d, Z : %3d, N : %3d" % (Z+N, Z, N))
print("<br> Jpi : %3s" % (temp['jp'][0])) print("<br> Jpi : %3s" % (temp['jp'][0]))
if halfLife != " " : #if halfLife != " " :
print(", half-live : %s sec" % (halfLife)) print("<br> half-live : %s sec" % (halfLife))
print("<br> Mass : %.4f MeV" % (mass)) print("<br> Mass : %.4f MeV" % (mass))
print("<br> Binding : %.4f MeV/A" % (temp['binding']/1000)) print("<br> Binding : %.4f MeV/A" % (temp['binding']/1000))
print("<br> Binding : %.4f MeV" % (temp['binding']/1000*(Z+N))) print("<br> Binding : %.4f MeV" % (temp['binding']/1000*(Z+N)))
@ -87,7 +87,7 @@ if float(maxEx) > 0 :
print("<table>") print("<table>")
for i in range(0, l+1): for i in range(0, l+1):
if float(ex[i]) < float(maxEx)*1000: if float(ex[i]) < float(maxEx)*1000:
print("<tr><td style=\"text-align:right\" width=80> %9.3f </td><td style=\"text-align:right\" width = 100> %s</td></tr>" % (ex[i], jp[i])) print("<tr><td style=\"text-align:right\" width=80> %9.3f </td><td style=\"text-align:right\" width=100> %s </td></tr>" % (ex[i], jp[i].replace(' ', ',')))
else: else:
break break
print("</table>") print("</table>")

View File

@ -3,6 +3,7 @@
<head> <head>
<title>Heliosmatics</title> <title>Heliosmatics</title>
<meta name="description" content="HELIOSmatics was first built by Ben P. Kay in MS Excel around 2010. Later, it was modified by Ryan Tang. Now, it migrates to web."> <meta name="description" content="HELIOSmatics was first built by Ben P. Kay in MS Excel around 2010. Later, it was modified by Ryan Tang. Now, it migrates to web.">
<link rel="icon" type="image/x-icon" href="SOLARIS_favicon.png">
<script src="https://cdn.plot.ly/plotly-2.16.1.min.js"></script> <script src="https://cdn.plot.ly/plotly-2.16.1.min.js"></script>
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, user-scalable=no, user-scalable=0"/> <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, user-scalable=no, user-scalable=0"/>
</head> </head>
@ -438,12 +439,12 @@ function CopyInputs(){
if( inputs[i].type == 'text'){ if( inputs[i].type == 'text'){
//console.log(inputs[i].id.substring(0,2)); //console.log(inputs[i].id.substring(0,2));
if( inputs[i].id.substring(0,2) == 'Ex' || inputs[i].id.substring(0,5) == 'theta' ) { if( inputs[i].id.substring(0,2) == 'Ex' || inputs[i].id.substring(0,5) == 'theta' ) {
continue; continue;
} }
if( inputs[i].id == 'innerRecoil'){ if( inputs[i].id == 'innerRecoil'){
break; break;
} }
copyText += inputs[i].value + ", "; copyText += inputs[i].value + ", ";
} }
} }

View File

@ -191,8 +191,8 @@ function CalConstants(){
KEA = document.getElementById('KEA').value; KEA = document.getElementById('KEA').value;
KE = KEA * beam[0]; KE = KEA * beam[0];
reactionName = beam[3] +"(" + target[3] + "," + light[3] + ")" + heavy[3] + "@" + KEA + "MeV/u"; reactionName = beam[3] +"(" + target[3] + "," + light[3] + ")" + heavy[3] + "@" + KEA + "MeV/u, " + BField.toFixed(1) + " T";
Qvalue = - heavy[2] - light[2] + beam[2] + target[2] ; Qvalue = - heavy[2] - light[2] + beam[2] + target[2] ;
minKEA = (Math.pow(light[2] + heavy[2],2) - Math.pow(beam[2] + target[2],2))/2/target[2]/beam[0]; minKEA = (Math.pow(light[2] + heavy[2],2) - Math.pow(beam[2] + target[2],2))/2/target[2]/beam[0];

View File

@ -237,6 +237,10 @@ pngName=haha.splitlines().pop()
print ("Content-Type: text/html\r\n\r\n") print ("Content-Type: text/html\r\n\r\n")
print ("<html>") print ("<html>")
print ("<head>")
print ("<title>Result of DWBA and Monte Carlo Simulation</title>")
print ("<link rel=\"icon\" type=\"image/x-icon\" href=\"SOLARIS_favicon.png\">")
print ("</head>")
print ("<style> img {max-width: 100%} </style>") print ("<style> img {max-width: 100%} </style>")
print ("<style> body { font-family: courier, courier new, serif; background: #6DB33E} </style>") print ("<style> body { font-family: courier, courier new, serif; background: #6DB33E} </style>")
#print ("<style> a { color: #F7CF3C;} </style>") #print ("<style> a { color: #F7CF3C;} </style>")

View File

@ -2,6 +2,8 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>DWBA and Monte Carlo Simulation</title>
<link rel="icon" type="image/x-icon" href="SOLARIS_favicon.png">
</head> </head>
<style> <style>
body { body {
@ -29,7 +31,7 @@
<td>Beam </td> <td>Beam </td>
<td><input type = "text" name = "beam_AZ" size="5" value="16O"/></td> <td><input type = "text" name = "beam_AZ" size="5" value="16O"/></td>
<td style="text-align:right">J<sup>&pi;</sup></td> <td style="text-align:right">J<sup>&pi;</sup></td>
<td><input type = "text" name = "beam_Jpi" size="5" value="0+"/><td> <td><input type = "text" id="beam_Jpi" name = "beam_Jpi" size="5" value="0+"/><td>
<td style="text-align:right">Ex:</td> <td style="text-align:right">Ex:</td>
<td><input type = "text" name = "beam_Ex" size="5" value="0.00"/></td> <td><input type = "text" name = "beam_Ex" size="5" value="0.00"/></td>
<td style="text-align:left">MeV</td> <td style="text-align:left">MeV</td>
@ -76,23 +78,35 @@
<h3>DWBA and E<sub>x</sub> List:</h3> <h3>DWBA and E<sub>x</sub> List:</h3>
<p> for 2-nucleon transfer, Orbital take the form nL=X, where n is number of node, X is momnetum number.</p> <p> for 2-nucleon transfer, Orbital take the form nL=X, where n is number of node, X is momnetum number.</p>
<p> TODO: add button to add known states with parity selection</p>
TODO: guess the orbital
<br>
<input type="checkbox" id="pos" onclick="checkParity()" checked/>Positive parity</td>
<input type="checkbox" id="neg" onclick="checkParity()" checked/>Negative parity</td>
<input type="checkbox" id="unk" onclick="checkParity()" checked/>Unknown parity</td>
<br>
<button type="button" onclick="addStates()">Add known states</button>
Isotope: <input type="text" id="AZ" size="5" value="17O"/>
Max Ex: <input type="text" id="maxEx" size="5" value="5"/>MeV
<p id='waiting'></p>
<table id="ExTable"> <table id="ExTable">
<tr> <tr>
<td> E<sub>x</sub> [MeV]</td> <td> E<sub>x</sub> [MeV]</td>
<td> J<sup>&#960;</sup></td> <td> &nbsp;&nbsp;&nbsp;J<sup>&#960;</sup></td>
<td> Orbital </td> <td> Orbital </td>
</tr> </tr>
</tr> </tr>
<td><input type="text" name="Ex" size="5" value="0"/></td> <td><input type="text" name="Ex" size="5" value="0"/></td>
<td><input type="text" name="Jpi" size="5" value="3/2+"/></td> <td><input type="text" name="Jpi" size="5" value="3/2+"/></td>
<td><input type="text" name="Orb" size="5" value="0d3/2"/></td> <td><input type="text" name="Orb" size="6" value="0d3/2"/></td>
</tr> </tr>
<tr> <tr>
<td><button type="button" onclick="addRow()">Add Ex</button></td> <td><button type="button" onclick="addRow()">Add Ex</button></td>
<td></td>
<td><button type="button" onclick="deleteRow()">Remove Ex</button></td> <td><button type="button" onclick="deleteRow()">Remove Ex</button></td>
<td><button type="button" onclick="copyEx()">Copy</button></td>
<td><button type="button" onclick="pasteEx()">Paste</button></td>
</tr> </tr>
</table> </table>
@ -295,7 +309,7 @@ function GetClipBoard(){
function(result){ function(result){
//console.log(result); //console.log(result);
if( result.substring(0,16) == "====HELIOSMATICS" ){ if( result.substring(0,16) == "====HELIOSMATICS" ){
let haha = result.substring(17).split(', '); let haha = result.substring(17).split(', ');
//console.log(haha); //console.log(haha);
//alert(haha); //alert(haha);
document.getElementsByName('beam_AZ')[0].value = haha[0]; document.getElementsByName('beam_AZ')[0].value = haha[0];
@ -314,13 +328,148 @@ function GetClipBoard(){
GetClipBoard(); GetClipBoard();
function copyEx(){
let inputs = document.getElementsByTagName("input");
let copyText = "====ExList|";
for(let i = 0; i < inputs.length; i++){
if( inputs[i].type == 'text'){
if( inputs[i].name == "Ex" || inputs[i].name == "Jpi" || inputs[i].name == "Orb" ){
//if( inputs[i].value == "" ) continue;
copyText += inputs[i].value;
if(inputs[i].name == "Orb") {
copyText += "|";
}else{
copyText += ",";
}
}
}
}
//console.log(copyText);
navigator.clipboard.writeText(copyText).then(
() => {
alert('Ex are copied to clipboard.\n' + copyText);
}).catch(
() =>{
alert('Cannot copy.');
});
}
function pasteEx(){
navigator.clipboard.readText().then(
function(result){
//console.log(result);
if( result.substring(0,10) == "====ExList" ){
let haha = result.substring(11).split('|');
//console.log(haha);
let table = document.getElementById("ExTable");
let nRow = table.rows.length;
//console.log(nRow);
//remove all Row except the 1st
for( let i = nRow; i > 2; i--){
table.deleteRow(i - 2);
}
for( let i = 0; i < haha.length; i++){
if( haha[i] == "" ) continue;
let kaka = haha[i].split(',');
//console.log(kaka);
nRow = table.rows.length;
let row = table.insertRow(nRow-1);
row.innerHTML = '<td><input type="text" name="Ex" size="5" value="' + kaka[0] + '"/></td> \
<td><input type="text" name="Jpi" size="5" value="' + kaka[1] + '"/></td> \
<td><input type="text" name="Orb" size="6" value="' + kaka[2] + '"/></td>';
}
}
}
);
}
let parity;
function checkParity(){
parity = 0;
if( document.getElementById('pos').checked == true ) parity += 1;
if( document.getElementById('neg').checked == true ) parity += 2;
if( document.getElementById('unk').checked == true ) parity += 4;
//console.log(parity);
}
checkParity();
function addStates(){
let AZ = document.getElementById('AZ').value;
let maxEx = document.getElementById('maxEx').value;
let beamJpi = document.getElementById('beam_Jpi').value;
let str = 'get_nuclear_data.py?isotopes_name=' + AZ + '&maxEx='+maxEx;
let table = document.getElementById("ExTable");
let nRow = table.rows.length;
for( let j = nRow; j > 2; j--){
table.deleteRow(j - 2);
}
console.log("========================= " + nRow);
const client = new XMLHttpRequest();
client.addEventListener('loadstart',
function(e){
document.getElementById('waiting').innerHTML = "wait....retrieving data..";
}
);
client.addEventListener('loadend',
function(e){
let result = client.responseText.split(/\r?\n/);
//console.log(result);
document.getElementById('waiting').innerHTML = "";
for( let i = 0; i < result.length; i++){
//console.log(i + ", " + result[i]);
if( i < 17 ) continue;
if( result[i] == "</table>" ) break;
//console.log(result[i]);
let kaka = result[i].split(' ').filter(n => n);
//console.log(kaka);
let ex = parseFloat(kaka[3])/1000.;
let jpi = kaka[7]?.replace('(', '')?.replace(')', '');
console.log(ex + ", " + jpi);
//check parity
if( (((parity >> 2) & 1) != 1) && kaka[7].slice(-1) == ")" ) continue;
if( (((parity >> 2) & 1) != 1) && jpi == "," ) continue;
if( (((parity) & 1) != 1) && jpi.slice(-1) == "+" ) continue;
if( (((parity >> 1) & 1) != 1) && jpi.slice(-1) == "-" ) continue;
nRow = table.rows.length;
let row = table.insertRow(nRow-1);
row.innerHTML = '<td><input type="text" name="Ex" size="5" value="' + ex.toFixed(3) + '"/></td> \
<td><input type="text" name="Jpi" size="5" value="' + jpi + '"/></td> \
<td><input type="text" name="Orb" size="6" /></td>';
}
}
);
client.open('GET', str);
client.send();
}
function addRow() { function addRow() {
var table = document.getElementById("ExTable"); var table = document.getElementById("ExTable");
var nRow = table.rows.length; var nRow = table.rows.length;
var row = table.insertRow(nRow-1); var row = table.insertRow(nRow-1);
row.innerHTML = '<td><input type="text" name="Ex" size="5" /></td> \ row.innerHTML = '<td><input type="text" name="Ex" size="5" /></td> \
<td><input type="text" name="Jpi" size="5"/></td> \ <td><input type="text" name="Jpi" size="5"/></td> \
<td><input type="text" name="Orb" size="5"/></td>'; <td><input type="text" name="Orb" size="6"/></td>';
} }
function deleteRow(){ function deleteRow(){