added EnergyLevelsPlot
This commit is contained in:
parent
014a13340c
commit
9871bdeeaa
69
EnergyLevelsPlot.html
Normal file
69
EnergyLevelsPlot.html
Normal file
|
@ -0,0 +1,69 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Energy Levels Plot</title>
|
||||
<link rel="icon" type="image/x-icon" href="logos/SOLARIS_favicon.png">
|
||||
<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"/>
|
||||
</head>
|
||||
|
||||
<style>
|
||||
body{
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
background : #6DB33E;
|
||||
}
|
||||
.column{
|
||||
float : left;
|
||||
width: 650px;
|
||||
padding: 0px;
|
||||
}
|
||||
.row:after {
|
||||
content: "";
|
||||
display: table;
|
||||
clear: both;
|
||||
}
|
||||
.plotStyle{
|
||||
width:650px;
|
||||
height:600px;
|
||||
}
|
||||
hr {
|
||||
height:4px;
|
||||
background-color:#F7CF3C;
|
||||
border-style:none;
|
||||
border-width:none;
|
||||
}
|
||||
</style>
|
||||
|
||||
<body>
|
||||
|
||||
<h1>Energy Levels Plot</h1>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td style="text-align: right;"> Isotopes Name </td>
|
||||
<td><Input type="text" style="width:60px" value="18O" id="isotopes_name" enterkeyhint="done"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: right;"> Max Ex </td>
|
||||
<td><Input type="text" style="width:60px" value="6" id="maxEx" enterkeyhint="done"/></td>
|
||||
<td> MeV</td>
|
||||
</tr>
|
||||
<!-- <tr>
|
||||
<td style="text-align: right;"> PlotRange </td>
|
||||
<td><Input type="text" style="width:60px" value="6" id="plotRange" enterkeyhint="done"/></td>
|
||||
<td> fm</td>
|
||||
</tr> -->
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><button onclick="PlotLevels()" style="width:65px">Plot</button></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div id="Plot_Levels" class="plotStyle"></div>
|
||||
|
||||
<p></p>
|
||||
</body>
|
||||
|
||||
<script src="EnergyLevelsPlot.js"></script>
|
||||
|
||||
</html>
|
151
EnergyLevelsPlot.js
Normal file
151
EnergyLevelsPlot.js
Normal file
|
@ -0,0 +1,151 @@
|
|||
var energy = [];
|
||||
var jpi = [];
|
||||
var Name;
|
||||
|
||||
function GetData(){
|
||||
|
||||
Name = document.getElementById('isotopes_name').value;
|
||||
let maxEx = parseFloat(document.getElementById('maxEx').value);
|
||||
|
||||
console.log(maxEx);
|
||||
|
||||
let str = 'get_nuclear_data.py?isotopes_name=' + Name + "&maxEx=" + maxEx;
|
||||
|
||||
let client = new XMLHttpRequest();
|
||||
client.onreadystatechange = function() {
|
||||
let haha = client.responseText.split('\n').slice(17);
|
||||
|
||||
jpi = [];
|
||||
energy = [];
|
||||
haha.forEach(line =>{
|
||||
// console.log(line);
|
||||
if( line.includes("<tr><td style=") && line.length != 0) {
|
||||
jpi.push(line.substring(98).slice(0,-10).trim());
|
||||
energy.push(parseFloat(line.substring(43,54).trim())/1000.);
|
||||
// console.log(jpi[jpi.length - 1] + ", " + energy[energy.length-1]);
|
||||
}
|
||||
});
|
||||
}
|
||||
client.open('GET', str, false);
|
||||
client.send();
|
||||
|
||||
}
|
||||
function PlotLevels(){
|
||||
|
||||
GetData();
|
||||
|
||||
Plotly.purge("Plot_Levels");
|
||||
|
||||
if( energy.length == 0 ) return;
|
||||
|
||||
// console.log( Name + " | num. states : " + energy.length);
|
||||
|
||||
const plotWidth = 300;
|
||||
const plotHeight = 600;
|
||||
const yMin = -1;
|
||||
const maxExExp = Math.max(...energy);
|
||||
|
||||
// console.log(maxExExp);
|
||||
|
||||
// let maxY = parseFloat(document.getElementById('plotRange').value);
|
||||
|
||||
const fig = {
|
||||
data: [],
|
||||
layout: {
|
||||
plot_bgcolor: 'white',
|
||||
width: plotWidth,
|
||||
height: plotHeight,
|
||||
margin: { l: 0, r: 0, t: 0, b: 0 },
|
||||
showlegend: false,
|
||||
xaxis: {
|
||||
showline: false,
|
||||
visible: false,
|
||||
range: [-0.5, 3]
|
||||
},
|
||||
yaxis: {
|
||||
range: [yMin, maxExExp + 1],
|
||||
showline: false,
|
||||
visible: false
|
||||
},
|
||||
annotations: []
|
||||
}
|
||||
};
|
||||
|
||||
const l = energy.length;
|
||||
|
||||
const fontSize = 14;
|
||||
const fontSizeMeV = fontSize / plotHeight * (maxExExp + 1 - yMin);
|
||||
|
||||
let ypos = [];
|
||||
for( let i = 0; i < energy.length; i++) ypos.push(energy[i]);
|
||||
|
||||
let noOverlap = false;
|
||||
let loop = 0;
|
||||
|
||||
while (!noOverlap && loop < 2 * l) {
|
||||
for (let i = 1; i <= l; i++) {
|
||||
const diff = ypos[i] - ypos[i - 1];
|
||||
if (diff < fontSizeMeV) {
|
||||
ypos[i - 1] += (diff - fontSizeMeV) / 2;
|
||||
ypos[i] += (fontSizeMeV - diff) / 2;
|
||||
if (ypos[i - 1] < yMin + fontSizeMeV / 2) {
|
||||
ypos[i - 1] = yMin + fontSizeMeV / 2;
|
||||
ypos[i] = ypos[i - 1] + fontSizeMeV;
|
||||
}
|
||||
}
|
||||
}
|
||||
let count = 0;
|
||||
for (let i = 1; i <= l; i++) {
|
||||
const diff = ypos[i] - ypos[i - 1];
|
||||
if (diff > fontSizeMeV) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (count === l) {
|
||||
noOverlap = true;
|
||||
}
|
||||
loop++;
|
||||
}
|
||||
|
||||
for (let i = 0; i < l; i++) {
|
||||
fig.data.push({
|
||||
x: [0, 1],
|
||||
y: [energy[i], energy[i]],
|
||||
mode: 'lines',
|
||||
line: { color: 'black', width: 1 }
|
||||
});
|
||||
|
||||
fig.data.push({
|
||||
x: [1.03, 1.1, 1.19],
|
||||
y: [energy[i], ypos[i], ypos[i]],
|
||||
mode: 'lines',
|
||||
line: { color: 'gray', width: 1 }
|
||||
});
|
||||
|
||||
// console.log(energy[i]+ ", " + ypos[i]);
|
||||
|
||||
fig.layout.annotations.push({
|
||||
x: 1.2,
|
||||
y: ypos[i],
|
||||
text: `${energy[i].toFixed(3)}, ${jpi[i]}`,
|
||||
xanchor: 'left',
|
||||
font: { size: fontSize },
|
||||
showarrow: false
|
||||
});
|
||||
}
|
||||
|
||||
// let NameYPos = (parseFloat(maxEx) + 2*fontSizeMeV);
|
||||
// console.log(NameYPos);
|
||||
|
||||
fig.layout.annotations.push({
|
||||
x: 0.5,
|
||||
y: (parseFloat(maxEx) + 0.5),
|
||||
text: Name,
|
||||
font: { size: 2 * fontSize },
|
||||
showarrow: false
|
||||
});
|
||||
|
||||
// Create the plot
|
||||
Plotly.newPlot('Plot_Levels', fig.data, fig.layout);
|
||||
|
||||
}
|
|
@ -16,8 +16,8 @@ def lc_read_csv(url):
|
|||
req.add_header('User-Agent', 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:77.0) Gecko/20100101 Firefox/77.0')
|
||||
return pd.read_csv(urllib.request.urlopen(req))
|
||||
|
||||
mp = 938.27208816; #MeV/c^2
|
||||
mn = 939.56542052;
|
||||
mp = 938.27208816 #MeV/c^2
|
||||
mn = 939.56542052
|
||||
|
||||
#===================================================
|
||||
import cgi, cgitb
|
||||
|
@ -31,7 +31,7 @@ if maxEx == "can be omitted" :
|
|||
maxEx = -1
|
||||
|
||||
query = livechart + "fields=ground_states&nuclides=" + AZ
|
||||
temp = lc_read_csv(query);
|
||||
temp = lc_read_csv(query)
|
||||
|
||||
print( "Content-type:text/html\r\n\r\n")
|
||||
print("<html>")
|
||||
|
|
20
index.html
20
index.html
|
@ -7,6 +7,7 @@
|
|||
</head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<script src="https://cdn.plot.ly/plotly-2.16.1.min.js"></script>
|
||||
<style>
|
||||
|
||||
:root{
|
||||
|
@ -124,7 +125,7 @@
|
|||
<td style="text-align:right"><a href="instruction.html" target="uploaded">Intructions & Credits</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:right"><a href="test.html" target="_blank">Woods-Saxon (const.)</a></td>
|
||||
<td style="text-align:right"><a href="test.html" target="_blank">Woods-Saxon</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:right"><a href="nuclearChart.html" target="_blank">Nuclides Chart (const.)</a></td>
|
||||
|
@ -137,21 +138,25 @@
|
|||
<table class="center">
|
||||
<tr>
|
||||
<td style="text-align:right">Isotopes Name:</td>
|
||||
<td><input type = "text" name = "isotopes_name" size="13" value="24F" enterkeyhint="done"/></td>
|
||||
<td><input type = "text" name = "isotopes_name" id="isotopes_name" size="13" value="24F" enterkeyhint="done"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:right">Max Ex [MeV]:</td>
|
||||
<td><input type = "text" name = "maxEx" size="13" value="can be omitted" enterkeyhint="done"/></td>
|
||||
<td><input type = "text" name = "maxEx" id="maxEx" size="13" value="can be omitted" enterkeyhint="done"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<!-- <tr>
|
||||
<td></td>
|
||||
<td>
|
||||
<input type = "submit" value = "Get Isotopes Data" />
|
||||
<input type = "submit" value = "Get Isotopes Data"/>
|
||||
</td>
|
||||
</tr> -->
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><button onclick="PlotLevels()" style="width: 130px;">Get Isotopes Data</button></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<div id="Plot_Levels" class="plotStyle"></div>
|
||||
<iframe name="NuclearData" style="border:none;width:100%;height:100%" ></iframe>
|
||||
|
||||
</nav>
|
||||
|
@ -162,6 +167,9 @@
|
|||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
<script src="EnergyLevelsPlot.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
/*
|
||||
|
|
|
@ -281,11 +281,11 @@ Max Ex: <input type="text" id="maxEx" size="5" value="5"/>MeV
|
|||
<td><input type = "file" name = "filename4a" /> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:right" width="200">Plot Config File * </th>
|
||||
<td style="text-align:right" width="200">Plot Config File # </th>
|
||||
<td><input type = "file" name = "filename5" /> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>^ can be alone <br>* can be omitted</th>
|
||||
<td>^ can be alone <br># can be omitted</th>
|
||||
<td><input type = "submit" value = "Upload & Run Simulation" style="height:50px; width:200px" formtarget="_blank"/> </td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
101
test.cpp
101
test.cpp
|
@ -18,6 +18,7 @@
|
|||
#include "implot.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
#include "WS.h"
|
||||
|
@ -92,10 +93,15 @@ void loop(){
|
|||
ImGui::End();
|
||||
}
|
||||
|
||||
// Woods-Saxon window
|
||||
{
|
||||
ImGui::SetNextWindowSize(ImVec2(600, 1000), ImGuiCond_FirstUseEver);
|
||||
ImGui::SetNextWindowPos(ImVec2(50, 50), ImGuiCond_FirstUseEver);
|
||||
|
||||
{
|
||||
ImGui::Begin("Woods-Saxon Calculation");
|
||||
|
||||
if( ImGui::BeginTabBar("Woods-Saxon", ImGuiTabBarFlags_None)){
|
||||
if (ImGui::BeginTabItem("Cal.")){
|
||||
|
||||
static float V0 = -45, r0 = 1.25, R0 = 3.5, a0 = 0.6;
|
||||
static float VSO = 28, rSO = 1.25, RSO = 3.5, aSO = 0.6;
|
||||
static int Z = 0, nStep = 300;
|
||||
|
@ -103,8 +109,6 @@ void loop(){
|
|||
static int A = 20;
|
||||
static float mass = 939.565;
|
||||
|
||||
ImGui::Begin("Woods-Saxon Calculation");
|
||||
|
||||
static int e = 0;
|
||||
if( ImGui::RadioButton("Arbitary", &e, 0) ){
|
||||
A = 1;
|
||||
|
@ -255,14 +259,11 @@ void loop(){
|
|||
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
//*============= WS Trend
|
||||
{
|
||||
ImGui::SetNextWindowSize(ImVec2(600, 800), ImGuiCond_FirstUseEver);
|
||||
ImGui::SetNextWindowPos(ImVec2(680, 50), ImGuiCond_FirstUseEver);
|
||||
if( ImGui::BeginTabItem("Range")){
|
||||
|
||||
static float V0 = -45, r0 = 1.25, a0 = 0.6;
|
||||
static float VSO = 28, rSO = 1.25, aSO = 0.6;
|
||||
static int Z = 0, N = 1, nStep = 300;
|
||||
|
@ -273,8 +274,6 @@ void loop(){
|
|||
static float mass = 939.565;
|
||||
static float kappa = -1;
|
||||
|
||||
ImGui::Begin("Woods-Saxon Calculation (Range)");
|
||||
|
||||
static int e = 0;
|
||||
ImGui::RadioButton("Stablility", &e, 0); ImGui::SameLine();
|
||||
ImGui::RadioButton("var. A", &e, 1); ImGui::SameLine();
|
||||
|
@ -324,7 +323,6 @@ void loop(){
|
|||
ImGui::SameLine();
|
||||
ImGui::DragFloat("dr [fm]", &dr, 0.001, 0.01, 0.1);
|
||||
|
||||
|
||||
int ARange[2] ;
|
||||
int fixedNZ;
|
||||
if( e == 0 || e == 1 ) {ARange[0] = A[0]; ARange[1] = A[1]; fixedNZ = 0;}
|
||||
|
@ -338,6 +336,7 @@ void loop(){
|
|||
}
|
||||
|
||||
orbitalStr.clear();
|
||||
{
|
||||
orbitalStr.push_back("0s1/2"); ///2
|
||||
orbitalStr.push_back("0p3/2");
|
||||
orbitalStr.push_back("0p1/2"); ///8
|
||||
|
@ -378,6 +377,7 @@ void loop(){
|
|||
orbitalStr.push_back("2d3/2");
|
||||
orbitalStr.push_back("1g7/2"); ///184
|
||||
}
|
||||
}
|
||||
|
||||
static float progress = 0;
|
||||
static bool cal = false;
|
||||
|
@ -496,10 +496,85 @@ void loop(){
|
|||
}
|
||||
}
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
if( ImGui::BeginTabItem("Fit")){
|
||||
ImGui::Text("to be impletment....");
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
ImGui::EndTabBar();
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
/*
|
||||
ImGui::SetNextWindowSize(ImVec2(1000, 400), ImGuiCond_FirstUseEver);
|
||||
ImGui::SetNextWindowPos(ImVec2(680, 50), ImGuiCond_FirstUseEver);
|
||||
{
|
||||
ImGui::Begin("Ptolemy");
|
||||
|
||||
const int maxCount = 20;
|
||||
static char reactionChar[maxCount][40];
|
||||
static char gsSpinChar[maxCount][10];
|
||||
static char KEAChar[maxCount][10];
|
||||
static char orbitalChar[maxCount][10];
|
||||
static char ExChar[maxCount][10];
|
||||
static char jpiChar[maxCount][10];
|
||||
static char potInChar[maxCount][10];
|
||||
static char potOutChar[maxCount][10];
|
||||
|
||||
static int count = 1;
|
||||
ImGui::InputInt("Number of states", &count, 1);
|
||||
|
||||
const int nCol = 8;
|
||||
if( ImGui::BeginTable("Input", nCol, ImGuiTableFlags_None) ){
|
||||
|
||||
{//Header
|
||||
ImGui::TableNextColumn(); ImGui::Text("Reaction");
|
||||
ImGui::TableNextColumn(); ImGui::Text("G.S. Spin");
|
||||
ImGui::TableNextColumn(); ImGui::Text("Energy [MeV/u]");
|
||||
ImGui::TableNextColumn(); ImGui::Text("Orbital");
|
||||
ImGui::TableNextColumn(); ImGui::Text("Ex [MeV]");
|
||||
ImGui::TableNextColumn(); ImGui::Text("J-pi");
|
||||
ImGui::TableNextColumn(); ImGui::Text("Pot-in");
|
||||
ImGui::TableNextColumn(); ImGui::Text("Pot-out");
|
||||
ImGui::TableNextRow();
|
||||
}
|
||||
|
||||
|
||||
for( int i = 0; i < count; i++){
|
||||
|
||||
ImGui::TableNextColumn(); ImGui::InputText(" ", reactionChar[i], 40) ;
|
||||
ImGui::TableNextColumn(); ImGui::InputText(" ", gsSpinChar[i], 10) ;
|
||||
ImGui::TableNextColumn(); ImGui::InputText(" ", KEAChar[i], 10) ;
|
||||
ImGui::TableNextColumn(); ImGui::InputText(" ", orbitalChar[i], 10) ;
|
||||
ImGui::TableNextColumn(); ImGui::InputText(" ", ExChar[i], 10) ;
|
||||
ImGui::TableNextColumn(); ImGui::InputText(" ", jpiChar[i], 10) ;
|
||||
ImGui::TableNextColumn(); ImGui::InputText(" ", potInChar[i], 10) ;
|
||||
ImGui::TableNextColumn(); ImGui::InputText(" ", potOutChar[i], 10) ;
|
||||
ImGui::TableNextRow();
|
||||
}
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
if( ImGui::Button("Calculate") ){
|
||||
|
||||
///==== create infile
|
||||
|
||||
///==== run Ptolemy
|
||||
|
||||
///==== extract d.s.c. from out file
|
||||
|
||||
///==== plot
|
||||
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
ImGui::Render();
|
||||
|
||||
int display_w, display_h;
|
||||
|
|
Loading…
Reference in New Issue
Block a user