First working implementation of more than 5 elements.

This commit is contained in:
2023-01-25 16:40:13 +01:00
parent 065fc74269
commit b18ec1c5fe
4 changed files with 33 additions and 75 deletions

View File

@@ -1194,21 +1194,17 @@ function CreateInpFile() {
// This is the flag for checking layers
let Check=0;
let Layer='';
let Li='';
// This contains mapped object pairs of original:replace
let repAll = new Object();
// Loop over layers an create appropriate values
for (var i=1; i<=All['numLayer'];i++){
Li = 'L'+i;
Layer = TemplateLayer;
Layer = Layer.replace(/L1/g,Li);
TemplateFile = TemplateFile+"\n"+Layer;
// Arry containing 12 lines for each layer
let newLayer = ["","","","","","","","","","","",""];
Check=0;
// Composition of layers
let LComp="L"+i+"Comp";
let Comp = document.getElementById(LComp).value;
All[LComp] = Comp;
let Comp = All[LComp];
if (Comp == "" || typeof Comp == 'undefined') {Check++;}
let LElComp=parse_formula(Comp);
for (key of Object.keys(LElComp)) {
// Check if composition is understood
@@ -1216,24 +1212,23 @@ function CreateInpFile() {
Check++;
}
}
if (Comp == "" || typeof Comp == 'undefined') {Check++;}
// Write composition to results file header
// Number of elements
let LElem = "L"+i+"Elem";
All[LElem] = Object.keys(LElComp).length;
let nEl = All[LElem];
// Densities of layers
let Lrho="layer"+i+"rho";
let Lrho="L"+i+"rho";
let rho = 1*All[Lrho];
if (rho=="") {Check++;}
if (rho==0) {Check++;}
// Thickness of layers
let Ld ="L"+i+"d";
let d = All[Ld];
if (d=="") {Check++;}
// Sanity check, is the layer supposed to have value? are they all there?
if (Check!=0) {
ErrMsg="Error: Bad chemical formula in Layer $i.\nPlease check!\n";
@@ -1241,9 +1236,6 @@ function CreateInpFile() {
return ErrMsg;
}
let tmp = "L"+i+"CK";
All[tmp]=1.0;
let Sum = 0;
for (key of Object.keys(LElComp)) {
Sum=Sum+LElComp[key];
@@ -1252,35 +1244,26 @@ function CreateInpFile() {
let Els = Object.keys(LElComp);
for (let NEl=1;NEl<=5;NEl++) {
let El = "";
if (NEl <= Els.length) {
El = Els[NEl-1];
}
let LEkey = "L"+i+"EL";
let ElZ = elemPars[El].Z;
let ElW = elemPars[El].A;
let ElC = 0;
if (LElComp[El] != null){ElC=LElComp[El]/Sum;}
let ElE = elemPars[El].Elast;
let El030 = 30;
if (El=="") { El030 = 0.0;}
All[LEkey+"Z"+NEl]=ElZ;
All[LEkey+"W"+NEl]=ElW;
All[LEkey+"C"+NEl]=ElC;
All[LEkey+"E"+NEl]=ElE;
All["L"+i+"030"+NEl]=El030;
// first line: chemical formula, thickness, density, correction factor, number of elements
newLayer[0] += Comp + " " + d + " " + rho + " 1 " + nEl;
for (var j=0;j<Els.length;j++) {
let El = Els[j];
let ElSTs = StoppingCoefficients(El,All["flagICRU"]);
let j=1;
for (let iElST of ElSTs) {
LEkey = "L"+i+"ELST"+NEl+j;
j++;
All[LEkey]=iElST;
}
// Next 11 lines depend on number of elements
newLayer[1] += elemPars[El].Z + " " ;
newLayer[2] += elemPars[El].A + " " ;
newLayer[3] += LElComp[El]/Sum + " " ;
newLayer[4] += elemPars[El].Elast + " " ;
newLayer[5] += "30 " ;
newLayer[6] += "0 " ;
newLayer[7] += ElSTs[0] + " " ;
newLayer[8] += ElSTs[1] + " " ;
newLayer[9] += ElSTs[2] + " " ;
newLayer[10] += ElSTs[3] + " " ;
newLayer[11] += ElSTs[4] + " " ;
}
TemplateFile += "\n" + newLayer.join("\n");
}
for (let key of Object.keys(All)) {
@@ -1296,16 +1279,6 @@ function CreateInpFile() {
return TemplateFile;
}
function replaceAll(str,mapObj){
// Takes string str and replaces all mapped objects in it
// The mapped object are pairs of original:replace
var re = new RegExp(Object.keys(mapObj).join("|"),"gi");
return str.replace(re, function(matched){
return mapObj[matched.toLowerCase()];
});
}
function sum(array){
// Takes and array and returns the sum of its elements
let sum_array = array.reduce(function(a, b){
@@ -1504,11 +1477,9 @@ function plotProfiles(filenames) {
var plotDiv=win.document.getElementById("newPlot");
// Extract energies from run files if available
//var files= new Object();
var Es = [];
for (let i=0;i<filenames.length;i++) {
Es[i]=Number(filenames[i].substring(filenames[i].indexOf('_')+2,filenames[i].indexOf('.')));
//files[Es[i]] = filenames[i];
}
// loop on sorted values and plot
@@ -1580,7 +1551,7 @@ function plotMean(filename) {
function startSim() {
// Collect data from GUI
var All=prep_cfg(1);
All=prep_cfg(1);
// Switch to plots tab
document.getElementById("btnPlots").click();
// Clear plots first

View File

@@ -14,8 +14,8 @@ WARN = # -Wall -Wextra
DIALECT = -std=gnu
prefix = /usr/local
# OPS = -c $(DIALECT) $(WARN) $(DEBUG)
#FCFLAGS = $(DIALECT) $(WARN) $(DEBUG) -O3 -mcmodel=large
FCFLAGS = $(DIALECT) $(WARN) $(DEBUG) -O3 -mcmodel=medium
FCFLAGS = $(DIALECT) $(WARN) $(DEBUG) -O3 -mcmodel=large
#FCFLAGS = $(DIALECT) $(WARN) $(DEBUG) -O3 -mcmodel=medium
all : trimspNL

View File

@@ -58,7 +58,7 @@ C accordingly.
PARAMETER (MAXD=1000)
PARAMETER (MAXNL=100)
C Maximum number of elements in each layer, was limited to 5.
PARAMETER (MAXEL=5)
PARAMETER (MAXEL=10)
PARAMETER (MAXD1=MAXD+1)
PARAMETER (MAXD2=MAXD+2)
PARAMETER (MAXD5=MAXD*MAXEL)
@@ -108,7 +108,7 @@ C Maximum number of elements in each layer, was limited to 5.
C NJ(I) is the number of elements in layer I
INTEGER*4 NJ(MAXNL),JT(MAXNL),ILD(MAXNL),NJJ
INTEGER*4 LLL(64),JJJ(64),IK(64)
INTEGER*4 me(5000),nli(MAXNL),irpl(MAXNL)
INTEGER*4 me(5000),nli(0:MAXNL),irpl(MAXNL)
INTEGER*4 IT,NPROJ
INTEGER*4 IB,IBL
INTEGER*4 IIRP,IIPL,ICDTT,ICDTTR
@@ -304,7 +304,7 @@ C CHARACTER Variables
DATA PL4ST/0.D0/,PL5ST/0.D0/,PL6ST/0.D0/
DATA KIT/0/,KIS/0/,KIST/0/,NALL/0/,NPA/0/,NSA/0/,KIB/0/,MAXA/0/
DATA SEM/0.D0/,IT/0/,NPROJ/0/,NREC1/0/,NREC2/0/
DATA NH/0/,IB/0/,IBL/0/,NJ/MAXNL*0/,NLI/MAXNL*0/
DATA NH/0/,IB/0/,IBL/0/,NJ/MAXNL*0/,NLI/0,MAXNL*0/
DATA DLI/MAXNL*0.D0/
DATA tryE/0/,negE/0/
DATA IIRP/0/,IIPL/0/,ICDTT/0/,ICDTTR/0/,TDMENR/0.D0/
@@ -422,37 +422,26 @@ C Possibly add the number of elements in the layer
READ(11,*) chem(I),DX(I),RHO(I),CK(I),NJ(I)
C Replace the following lines with read(11,*) (a(i,j), j = 1, 5)
C Atomic numbers
C READ(11,*) ZT(I,1),ZT(I,2),ZT(I,3),ZT(I,4),ZT(I,5)
read(11,*) (ZT(I,j), j = 1, NJ(I))
C Mass numbers (amu)
C READ(11,*) MT(I,1),MT(I,2),MT(I,3),MT(I,4),MT(I,5)
read(11,*) (MT(I,j), j = 1, NJ(I))
C Concentration (stoichiometry)
C READ(11,*) CO(I,1),CO(I,2),CO(I,3),CO(I,4),CO(I,5)
read(11,*) (CO(I,j), j = 1, NJ(I))
C Surface binding energy
C READ(11,*) SBE(I,1),SBE(I,2),SBE(I,3),SBE(I,4),SBE(I,5)
read(11,*) (SBE(I,j), j = 1, NJ(I))
C Displacement energy, always 30 eV??
C READ(11,*) ED(I,1),ED(I,2),ED(I,3),ED(I,4),ED(I,5)
read(11,*) (ED(I,j), j = 1, NJ(I))
C Bulk binding energy, usually zero
C READ(11,*) BE(I,1),BE(I,2),BE(I,3),BE(I,4),BE(I,5)
read(11,*) (BE(I,j), j = 1, NJ(I))
C value A-1 of the ziegler tables
C READ(11,*) CH1(I,1),CH1(I,2),CH1(I,3),CH1(I,4),CH1(I,5)
read(11,*) (CH1(I,j), j = 1, NJ(I))
C value A-2 of the ziegler tables
C READ(11,*) CH2(I,1),CH2(I,2),CH2(I,3),CH2(I,4),CH2(I,5)
read(11,*) (CH2(I,j), j = 1, NJ(I))
C value A-3 of the ziegler tables
C READ(11,*) CH3(I,1),CH3(I,2),CH3(I,3),CH3(I,4),CH3(I,5)
read(11,*) (CH3(I,j), j = 1, NJ(I))
C value A-4 of the ziegler tables
C READ(11,*) CH4(I,1),CH4(I,2),CH4(I,3),CH4(I,4),CH4(I,5)
read(11,*) (CH4(I,j), j = 1, NJ(I))
C value A-5 of the ziegler tables
C READ(11,*) CH5(I,1),CH5(I,2),CH5(I,3),CH5(I,4),CH5(I,5)
read(11,*) (CH5(I,j), j = 1, NJ(I))
ENDDO
@@ -2497,9 +2486,7 @@ C
nli(i)=IDINT(xx(i)/cw+0.01)
enddo
do i=1,l
C we have a problem here, what is nli(i-1) for i=1 (assumed 0??)
do j=nli(i-1)+1,nli(i)
write(*,*) 'i=',i,'j=',j,nli(i-1)+1,nli(i)
irpl(i)=irpl(i)+irp(j)
enddo
enddo
@@ -3844,7 +3831,7 @@ C
CLOSE(UNIT=21)
CLOSE(UNIT=22)
CLOSE(UNIT=99)
8000 STOP
8000 CONTINUE
END

BIN
trimspNL

Binary file not shown.