From 9032336e7ce26597640c09f4373994448ba04ec4 Mon Sep 17 00:00:00 2001 From: Zaher Salman Date: Fri, 16 Sep 2022 14:11:28 +0000 Subject: [PATCH 1/5] Readme.md edited online with Bitbucket --- Readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Readme.md b/Readme.md index 5fd58bb..48e8f03 100644 --- a/Readme.md +++ b/Readme.md @@ -13,6 +13,7 @@ This is the fortran source code and GUI of TrimSP Monte-Carlo simulations. ### Supported platforms ### * Linux +* Online at: http://musruser.psi.ch/cgi-bin/TrimSP.cgi ### Installation ### ###### Fortran code compilation ###### From 630f3b742d8c18a3de641a38f49be4a9b1a83153 Mon Sep 17 00:00:00 2001 From: Zaher Salman Date: Fri, 16 Sep 2022 20:06:12 +0200 Subject: [PATCH 2/5] Added He projectiles. --- TrimSP.html | 1 + TrimSPlib.js | 2 ++ fortran/trimspNL.F | 10 ++++++---- main.js | 1 + 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/TrimSP.html b/TrimSP.html index 0344bce..62d3d0f 100644 --- a/TrimSP.html +++ b/TrimSP.html @@ -65,6 +65,7 @@ + diff --git a/TrimSPlib.js b/TrimSPlib.js index c46fff0..178f059 100644 --- a/TrimSPlib.js +++ b/TrimSPlib.js @@ -934,11 +934,13 @@ function sum(array){ function startSequence(All) { let cmd = ''; let trimBin = All['trimPath']+"/trimspNL"; + console.log(trimBin); // Check if the trimspNL binary is found if (!fileExists(trimBin)) { // if not found, try in PATH and hope for the best trimBin = "trimspNL"; } + console.log(trimBin); // Check if workPath exists otherwise create it checkDir(All['workPath']); // from TrimSPelec.js, Electron/Node specific diff --git a/fortran/trimspNL.F b/fortran/trimspNL.F index 50067f9..64b6ef9 100644 --- a/fortran/trimspNL.F +++ b/fortran/trimspNL.F @@ -1,6 +1,7 @@ -C Version TrimSpNL ----> N Layer +C Created June 2000 ---- Testversion C -C Created Juni 2000 ---- Testversion +C Version TrimSpNL ----> Expanded to heterostructures with N Layer +C Zaher Salman C C *** C * C * COPYRIGHT W.ECKSTEIN, IPP GARCHING, FRG @@ -10,8 +11,9 @@ C if you use this code please cite C C Eckstein, W. Computer Simulation of Ion-Solid Interactions; C Springer Series in Materials Science; -C Springer-Verlag: Berlin Heidelberg, 1991. +C Springer-Verlag: Berlin Heidelberg, 1991. C +C Historical overview: C PROGRAM TRVMC95 VERSION AT IPP GARCHING NOVEMBER 1995 C MOMENTS OF DISTRIBUTIONS (RANGE, ENERGY AND C ANGLE OF BACKSCATTERED AND SPUTTERED ATOMS) @@ -2325,7 +2327,7 @@ C C 2nd CALL DATE_AND_TIME C -C how many seconds are needed for the simulation ?? +C How many seconds are needed for the simulation ?? C CALL TimeStamp(day_stop,month_stop,year_stop, hour_stop,min_stop & ,sec_stop,seconds_stop_total) diff --git a/main.js b/main.js index 6053be4..04862b5 100644 --- a/main.js +++ b/main.js @@ -6,6 +6,7 @@ function createWindow () { height: 580, icon: "./appicons/icons/png/1024x1024.png", webPreferences: { + contextIsolation: false, nodeIntegration: true, nativeWindowOpen: true, enableRemoteModule: true, From 9724c86a40a4b8d183d3f2c73a9ca185f6b0a4a8 Mon Sep 17 00:00:00 2001 From: Zaher Salman Date: Wed, 21 Sep 2022 10:03:46 +0200 Subject: [PATCH 3/5] Add some comments to the file. Old input file format to be phased out by end of 2022. --- fortran/trimspNL.F | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/fortran/trimspNL.F b/fortran/trimspNL.F index 64b6ef9..09e2daa 100644 --- a/fortran/trimspNL.F +++ b/fortran/trimspNL.F @@ -181,6 +181,9 @@ C REAL Variables REAL*8 K2(MAXNL),CK(MAXNL),KLM1(MAXNL) REAL*8 SB(MAXNL),DLI(MAXNL) REAL*8 UpTiefe,LowTiefe +C ZT - atomin numbers, MT - mass numbers (amu), CO - concentration (stoichiometry) +C SBE - surface binding energy, ED - displacement energy, BE - bulk binding energy +C COM - ?? REAL*8 ZT(MAXNL,5),MT(MAXNL,5),CO(MAXNL,5) & ,SBE(MAXNL,5),ED(MAXNL,5),BE(MAXNL,5), & COM(5,MAXNL) @@ -189,6 +192,7 @@ C REAL Variables & ,KLM(MAXNL,MAXNL5) REAL*8 MU1(MAXNL5),EC1(MAXNL5),A1(MAXNL5),F1(MAXNL5),KL1(MAXNL5) & ,KOR1(MAXNL5) ,DI(MAXNL5),EP(MAXNL5),ZZ(MAXNL5),TM(MAXNL5) +C CH1,2,3,4,5 are values of A-1,2,3,4,5 of the Ziegler tables REAL*8 CH1(MAXNL,5),CH2(MAXNL,5),CH3(MAXNL,5) & ,CH4(MAXNL,5),CH5(MAXNL,5) REAL*8 CHM1(MAXNL) @@ -386,10 +390,9 @@ C LMAX as needed for the new format. JMAX=5 if (OldNew(innam).eq.1) then +C This part reads the input file (new format) OPEN(UNIT=99,file=errnam,STATUS='replace') OPEN(UNIT=11,file=innam,STATUS='unknown',ERR=1359) - -C This part reads the input file (new format) C First line: properties of projectile READ(11,*) Z1,M1,E0,Esig,ALPHA,ALPHASIG,EF,ESB,SHEATH,ERC C Second line: simulation related parameters @@ -429,10 +432,11 @@ C value A-5 of the ziegler tables READ(11,*) CH5(I,1),CH5(I,2),CH5(I,3),CH5(I,4),CH5(I,5) ENDDO else +C This part reads the input file (old format, 7 layers) +C To be phased out soon (aim for beginning of 2023). OPEN(UNIT=99,file=errnam,STATUS='replace') OPEN(UNIT=11,file=innam,STATUS='unknown',ERR=1359) -C This part reads the input file (old format, 7 layers) C First line: properties of projectile READ(11,*) Z1,M1,E0,Esig,ALPHA,ALPHASIG,EF,ESB,SHEATH,ERC C Second line: simulation related parameters From bea03ac0cf6bf2b3d539fe0c4fe355d66aff9f63 Mon Sep 17 00:00:00 2001 From: Zaher Salman Date: Wed, 21 Sep 2022 17:11:00 +0200 Subject: [PATCH 4/5] Adjust GUI to accept chemical formulae with floats instead of intigers --- TrimSPlib.js | 27 +++++++++++++++++++-------- fortran/trimspNL.F | 5 +++-- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/TrimSPlib.js b/TrimSPlib.js index 178f059..a383f23 100644 --- a/TrimSPlib.js +++ b/TrimSPlib.js @@ -1,11 +1,14 @@ -// This file contains function that are Javascript generic +// This file contains function that are generic Javascript for TrimSP function parse_formula (mf) { // This function takes a chemical formula and returns // an object that contains the atoms and their number + + // replace all types of brackets into () var mf = mf.replace(/\[/g,"(").replace(/\]/g,")").replace(/\{/g,"(").replace(/\}/g,")").replace(/\s+/g,""); if(/^\d+/.test(mf)) throw new SyntaxError("Molecular formula should not start with a number!"); var mol = {}; + // go into brackets and collect info while(mf.includes("(")){ var x = mf.lastIndexOf("("); var y = mf.indexOf(")", mf.lastIndexOf("(")); @@ -14,7 +17,7 @@ function parse_formula (mf) { var c = mf.substr(y+1); c = /^\d+/.exec(c); c=(c!= null)?Number(c[0]):1; - + // recursive var a = this.parse_formula(z); var b = ""; for(var k in a){ @@ -24,13 +27,19 @@ function parse_formula (mf) { } var m = ""; - while(m = /([A-Z]{1}[a-z]{0,}[0-9]{0,})/.exec(mf)){ + // Separate element name from stoichiometry + // while(m = /([A-Z]{1}[a-z]{0,}[0-9]{0,})/.exec(mf)){ + while(m = /([A-Z]{1}[a-z]{0,}[0-9]{0,}\.?[0-9]{0,})/.exec(mf)){ + // Element var m1 = /([A-Z]{1,}[a-z]{0,})/.exec(m[0]); - var m2 = /\d+/.exec(m[0]); + // Stoichiometry + //var m2 = /\d+/.exec(m[0]); + var m2 = /\d+\.?\d{0,}/.exec(m[0]); if(typeof mol[m1[0]] == 'undefined') mol[m1[0]]=(m2!=null)?Number(m2[0]):1; else mol[m1[0]] += (m2!=null)?Number(m2[0]):1; mf = mf.replace(m[0], ""); } + console.log("mol=",mol); return mol; } @@ -836,14 +845,15 @@ function CreateInpFile(All) { Check++; } } - if (Comp == "") {Check++;} + if (Comp == "" || typeof Comp == 'undefined') {Check++;} // Write composition to results file header // Densities of layers let Lrho="layer"+i+"rho"; let rho = 1*All[Lrho]; + // How to do this? All[Lrho]=sprintf("%6.2f",rho); - if (rho=="") {Check++;} + if (rho=="") {Check++;console.log("rho",rho);} // Thickness of layers let Ld ="L"+i+"d"; @@ -853,8 +863,8 @@ function CreateInpFile(All) { // Sanity check, is the layer supposed to have value? are they all there? if (Check!=0) { - ErrMsg="Error: Bad chemical formula in Layer $i.\nPleach check!\n"; - //print STDERR $ErrMsg; + ErrMsg="Error: Bad chemical formula in Layer $i.\nPlease check!\n"; + console.log($ErrMsg); return ErrMsg; } @@ -866,6 +876,7 @@ function CreateInpFile(All) { Sum=Sum+LElComp[key]; } if (Sum==0) {Sum=1;} + console.log("Sum=",Sum); let Els = Object.keys(LElComp); diff --git a/fortran/trimspNL.F b/fortran/trimspNL.F index 09e2daa..ef9f7f8 100644 --- a/fortran/trimspNL.F +++ b/fortran/trimspNL.F @@ -394,6 +394,7 @@ C This part reads the input file (new format) OPEN(UNIT=99,file=errnam,STATUS='replace') OPEN(UNIT=11,file=innam,STATUS='unknown',ERR=1359) C First line: properties of projectile +C Ordered as: Z, mass number (amu), imp. energy, dist. of imp. energy, angle, dist. angles, READ(11,*) Z1,M1,E0,Esig,ALPHA,ALPHASIG,EF,ESB,SHEATH,ERC C Second line: simulation related parameters C Ordered as: Number of particles, seed, seed, seed, initial depth, RD, depth increment, CA, KK0, KDEE1,KDEE2,IPOT @@ -406,13 +407,13 @@ C Third line: Number of layers C Here we read the NLayers structure DO I=1,NLayers C Thickness (DX), density (RHO), and correction factor (CK, it is -C always 1.0??) Atomic numbers +C always 1.0??) READ(11,*) DX(I),RHO(I),CK(I) C Atomic numbers READ(11,*) ZT(I,1),ZT(I,2),ZT(I,3),ZT(I,4),ZT(I,5) C Mass numbers (amu) READ(11,*) MT(I,1),MT(I,2),MT(I,3),MT(I,4),MT(I,5) -C Concentration +C Concentration (stoichiometry) READ(11,*) CO(I,1),CO(I,2),CO(I,3),CO(I,4),CO(I,5) C Surface binding energy READ(11,*) SBE(I,1),SBE(I,2),SBE(I,3),SBE(I,4),SBE(I,5) From 7ac303a99e54a0a6f64be009f37280c09f815faa Mon Sep 17 00:00:00 2001 From: Zaher Salman Date: Tue, 13 Dec 2022 13:29:37 +0100 Subject: [PATCH 5/5] Better handeling of working path --- TrimSP.html | 25 ++++++++++++++++++------- TrimSPlib.js | 3 +-- main.js | 11 +++++------ 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/TrimSP.html b/TrimSP.html index 62d3d0f..ca8f257 100644 --- a/TrimSP.html +++ b/TrimSP.html @@ -41,7 +41,7 @@ - + @@ -226,13 +226,21 @@ }); }); - let foldername = document.getElementById("workPath").value; - // If empty or undefined fill with default - if (foldername == '' || foldername == undefined ) {foldername ="/tmp/test";} + let workPath = document.getElementById("workPath"); + // If empty or undefined use local folder as default + if (workPath.value == '' || workPath.value == undefined ) { + workPath.value = process.cwd(); + // console.log("I am here",process.cwd()); + } // Catch calls for selectfolder ipcRenderer.on('selectFolder', function(event, foldername) { - document.getElementById("workPath").value = foldername; + if (foldername.length != 0) { + document.getElementById("workPath").value = foldername[0]; + // Change process directory + process.chdir(foldername[0]); + } + console.log("currentdir",process.cwd()); }); // Catch calls for save as ipcRenderer.on('saveFile', function(event, filename) { @@ -263,8 +271,11 @@ // Catch clicks for Browse button let browseBtn = document.getElementById('browseFolde'); ipcRenderer.on('browseFolder', function(event, foldername) { - document.getElementById("workPath").value = foldername; - console.log("foldername="+foldername); + if (foldername.length != 0) { + document.getElementById("workPath").value = foldername[0]; + // Change process directory + process.chdir(foldername[0]); + } }); // Get the element with id="defaultOpen" and click on it diff --git a/TrimSPlib.js b/TrimSPlib.js index a383f23..32ff5b6 100644 --- a/TrimSPlib.js +++ b/TrimSPlib.js @@ -853,7 +853,7 @@ function CreateInpFile(All) { let rho = 1*All[Lrho]; // How to do this? All[Lrho]=sprintf("%6.2f",rho); - if (rho=="") {Check++;console.log("rho",rho);} + if (rho=="") {Check++;} // Thickness of layers let Ld ="L"+i+"d"; @@ -876,7 +876,6 @@ function CreateInpFile(All) { Sum=Sum+LElComp[key]; } if (Sum==0) {Sum=1;} - console.log("Sum=",Sum); let Els = Object.keys(LElComp); diff --git a/main.js b/main.js index 04862b5..86c268f 100644 --- a/main.js +++ b/main.js @@ -1,5 +1,4 @@ const { app, BrowserWindow, Menu, dialog, ipcMain, fs } = require('electron'); - function createWindow () { const win = new BrowserWindow({ width: 950, @@ -14,7 +13,7 @@ function createWindow () { }) - const template = [ + let template = [ { label: 'File', submenu: [ @@ -24,7 +23,7 @@ function createWindow () { click () { dialog.showOpenDialog(win, { title : "Load configuration file", - defaultPath : "./", + //defaultPath : "./", //buttonLabel : "Custom button", filters :[ {name: 'Config file type', extensions: ['cfg']}, @@ -48,7 +47,7 @@ function createWindow () { click () { dialog.showOpenDialog(win, { title: "Select folder", - defaultPath : "./", + //defaultPath : "./", properties:["openDirectory"]} ).then(result => { console.log(result.filePaths) @@ -73,7 +72,7 @@ function createWindow () { click () { dialog.showSaveDialog(win, { title : "Save configuration file", - defaultPath : "./", + //defaultPath : "./", filters :[ {name: 'Config file type', extensions: ['cfg']}, {name: 'All Files', extensions: ['*']} @@ -226,7 +225,7 @@ app.on('activate', () => { // Reply to calls from browser button ipcMain.on('browseFolder', (event) => { dialog.showOpenDialog({ title: "Select folder", - defaultPath : "./", + //defaultPath : "./", properties:["openDirectory"]} ).then(result => { console.log(result.filePaths)