This commit is contained in:
2022-12-29 18:48:15 -04:00
5 changed files with 62 additions and 30 deletions
+2 -1
View File
@@ -15,6 +15,7 @@ an application for performing [Monte Carlo] simulations of ion implantation.
### Supported platforms ###
* [Linux]
* Online at: http://musruser.psi.ch/cgi-bin/TrimSP.cgi
### Installation ###
@@ -60,4 +61,4 @@ Zaher Salman <zaher.salman@psi.ch>
[DEB]: https://en.wikipedia.org/wiki/Deb_(file_format)
[Linux]: https://en.wikipedia.org/wiki/Linux
[Monte Carlo]: https://en.wikipedia.org/wiki/Monte_Carlo_method
[GUI]: https://en.wikipedia.org/wiki/Graphical_user_interface
[GUI]: https://en.wikipedia.org/wiki/Graphical_user_interface
+19 -7
View File
@@ -41,7 +41,7 @@
<tr>
<td><label>Save folder:</label></td>
<td>
<input type="text" style="width:70%" id="workPath" name="workPath" value="/tmp/test" readonly/>
<input type="text" style="width:70%" id="workPath" name="workPath" readonly/>
<input type="button" value="Browse"
id="browseFolde" onclick="ipcRenderer.send('browseFolder');">
</td>
@@ -66,6 +66,7 @@
<option value="boron-12">boron-12</option>
<option value="magnesium-31">magnesium-31</option>
<option value="H">H</option>
<option value="He">He</option>
</select>
</td>
</tr>
@@ -323,13 +324,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) {
@@ -360,8 +369,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
+19 -7
View File
@@ -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;
}
@@ -838,12 +847,13 @@ 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++;}
@@ -855,8 +865,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;
}
@@ -936,11 +946,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
+16 -9
View File
@@ -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 <zaher.salman@psi.ch>
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)
@@ -179,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)
@@ -187,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)
@@ -384,11 +390,11 @@ 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
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
@@ -401,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)
@@ -427,10 +433,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
@@ -2325,7 +2332,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)
+6 -6
View File
@@ -1,11 +1,11 @@
const { app, BrowserWindow, Menu, dialog, ipcMain, fs } = require('electron');
function createWindow () {
const win = new BrowserWindow({
width: 950,
height: 580,
icon: "./appicons/icons/png/1024x1024.png",
webPreferences: {
contextIsolation: false,
nodeIntegration: true,
nativeWindowOpen: true,
enableRemoteModule: true,
@@ -13,7 +13,7 @@ function createWindow () {
})
const template = [
let template = [
{
label: 'File',
submenu: [
@@ -23,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']},
@@ -47,7 +47,7 @@ function createWindow () {
click () {
dialog.showOpenDialog(win,
{ title: "Select folder",
defaultPath : "./",
//defaultPath : "./",
properties:["openDirectory"]}
).then(result => {
console.log(result.filePaths)
@@ -72,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: ['*']}
@@ -225,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)