Skip to content

Commit

Permalink
- Fixed loading of Simulation Files and introduced chaeck for sanity…
Browse files Browse the repository at this point in the history
… of lower and upper channel bounds

    - Added "Move Up" / "Move Down" buttons to layer list in target configurator
    - Changed precision of charge and detector calibration inputs to 4 in main window
    - Changed precision of areal density inputs in target configurator to 4
    - introduced option "open [simulation_file]" to be passed as argument for console operation
  • Loading branch information
DrReneHeller committed May 16, 2023
1 parent 9f8bb6e commit e9be40c
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 78 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,12 @@
- Reduced console output during DE optimization
- Bugfix: Re-binning to "1" after DE optimization and update of simulation
- Bugfix: Impact angle correction for BS yield


2023_05_16 - V7.7.1

- Fixed loading of Simulation Files and introduced chaeck for sanity of lower and upper channel bounds
- Added "Move Up" / "Move Down" buttons to layer list in target configurator
- Changed precision of charge and detector calibration inputs to 4 in main window
- Changed precision of areal density inputs in target configurator to 4
- introduced option "open [simulation_file]" to be passed as argument for console operation
2 changes: 1 addition & 1 deletion dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.ruthelde</groupId>
<artifactId>ruthelde</artifactId>
<version>7.7.0</version>
<version>7.7.1</version>
<build>
<plugins>
<plugin>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.ruthelde</groupId>
<artifactId>ruthelde</artifactId>
<version>7.7.0</version>
<version>7.7.1</version>
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/ruthelde/GA/GAEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ public boolean evolve(PlotWindow spectraPlotWindow, PlotWindow fitnessPlotWindow

boolean plotRefresh = false;

//TODO: Reduce the console output to just the gneration numer and make line break only ech 10 generations

//System.out.println("Starting calculation of new generation [" + generationCounter + "]");
System.out.print(generationCounter + "");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,8 @@ private double calFitness(){
}

//sigma2 = 100.0f / (Math.log(sigma2) - Math.log(LFF));
sigma2 = LFF / sigma2 * 100.0f;
//sigma2 = LFF / sigma2 * 100.0f;
sigma2 = Math.log(LFF) / Math.log(sigma2) * 100.0f;
return sigma2;
}

Expand Down
84 changes: 54 additions & 30 deletions src/main/java/com/ruthelde/Main/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,22 @@ public MainWindow(String args[]) {

if (args.length == 0) {

System.out.println("Usage: java -jar IBA.jar {help|run_de|simulate} [...]");
System.out.println("Usage: java -jar IBA.jar {help|run_de|simulate|open} [...]");
return;
}

if (args[0].equals("help")) {

System.out.println("Usage: java -jar IBA.jar {help|run_de|simulate} [...]");
System.out.println("Usage: java -jar IBA.jar {help|run_de|simulate|open} [...]");
System.out.println("help ");
System.out.println("run_de [input] [fileType] [spectrum_1 ... spectrum_N] runs differential evolution");
System.out.println(" [input] (absolute) path to IBA simulation file which is used to extract");
System.out.println(" input parameters like target model and experimental constrains from.");
System.out.println(" [fileType] specifies the tye of following iba spectra. Allowed values:");
System.out.println(" ASCII_ONE, ASCII_TWO, IBC_RBS, IBC_3MV_SINGLE, IBC_3MV_MULTI, IMEC, IBA_SIM");
System.out.println(" [spectrum_1 ... spectrum_N] (absolute) file paths to spectra files");
System.out.println("simulate [input-file] [output-file] Generate data from simulation");
System.out.println("simulate [input-file] [output-file] Generate data automatically from simulation");
System.out.println("open [input-file] Opens Ruthelde with specified simulation file");
System.exit(0);
}

Expand All @@ -167,6 +168,12 @@ public MainWindow(String args[]) {
System.exit(0);
}

if (args[0].equals("open")) {

System.out.println("Starting Ruthelde with specified simulation file");
loadSimulation(args[1]);
}

if (args[0].equals("run_de")) {

System.out.println("Importing parameters from simulation file.");
Expand Down Expand Up @@ -644,10 +651,33 @@ private boolean loadSimulation(String fileName) {

deParameter = df.deParameter;

if (deParameter.startCH >= df.experimentalSpectrum.length - 1) {

deParameter.startCH = df.experimentalSpectrum.length - 2;
System.out.print("Parameter *Start_Channel to high. Changed to ");
System.out.println("" + deParameter.startCH);
}

if (deParameter.endCH >= df.experimentalSpectrum.length - 1) {

deParameter.endCH = df.experimentalSpectrum.length - 2;
System.out.print("Parameter *End_Channel to high. Changed to ");
System.out.println("" + deParameter.endCH);
}

if (deParameter.startCH >= deParameter.endCH) {

deParameter.startCH = deParameter.endCH - 2;
System.out.print("Parameter *Start_Channel to high. Changed to ");
System.out.println("" + deParameter.startCH);
}

spectrumSimulator.setStartChannel(deParameter.startCH);
spectrumSimulator.setStopChannel(deParameter.endCH);
tf_ch_min.setText("" + (int) df.deParameter.startCH);
tf_ch_max.setText("" + (int) df.deParameter.endCH);
//tf_ch_min.setText("" + (int) df.deParameter.startCH);
//tf_ch_max.setText("" + (int) df.deParameter.endCH);
tf_ch_min.setText("" + (int) deParameter.startCH);
tf_ch_max.setText("" + (int) deParameter.endCH);
spectrumSimulator.setExperimentalSpectrum(df.experimentalSpectrum);
spectrumSimulator.applyStoppingCorrection();

Expand Down Expand Up @@ -723,7 +753,7 @@ private boolean loadSimulation(String fileName) {

} catch (Exception ex) {
result = false;
ex.toString();
ex.printStackTrace();
}

if (!result) System.out.println("Error loading simulation file.");
Expand Down Expand Up @@ -954,9 +984,9 @@ private void updateChargeValues() {
double minCharge = experimentalSetup.getMinCharge();
double maxCharge = experimentalSetup.getMaxCharge();

tfExpCharge.setText(Helper.dblToDecStr(charge, 2));
tfExpChargeMin.setText(Helper.dblToDecStr(minCharge, 2));
tfExpChargeMax.setText(Helper.dblToDecStr(maxCharge, 2));
tfExpCharge.setText(Helper.dblToDecStr(charge, 3));
tfExpChargeMin.setText(Helper.dblToDecStr(minCharge, 3));
tfExpChargeMax.setText(Helper.dblToDecStr(maxCharge, 3));
}

private void setExpCharge() {
Expand Down Expand Up @@ -1040,9 +1070,9 @@ private void updateDetDE() {
double minRes = detectorSetup.getMinRes();
double maxRes = detectorSetup.getMaxRes();

tfDetDE.setText(Helper.dblToDecStr(res, 2));
tfDetDEMin.setText(Helper.dblToDecStr(minRes, 2));
tfDetDEMax.setText(Helper.dblToDecStr(maxRes, 2));
tfDetDE.setText(Helper.dblToDecStr(res, 4));
tfDetDEMin.setText(Helper.dblToDecStr(minRes, 4));
tfDetDEMax.setText(Helper.dblToDecStr(maxRes, 4));
}

private void updateCalibration() {
Expand All @@ -1054,9 +1084,9 @@ private void updateCalibration() {
double offsetMin = detectorSetup.getCalibration().getOffsetMin();
double offsetMax = detectorSetup.getCalibration().getOffsetMax();

tfDetCalFactor.setText(Helper.dblToDecStr(factor, 2));
tfDetCalFactorMin.setText(Helper.dblToDecStr(factorMin, 2));
tfDetCalFactorMax.setText(Helper.dblToDecStr(factorMax, 2));
tfDetCalFactor.setText(Helper.dblToDecStr(factor, 4));
tfDetCalFactorMin.setText(Helper.dblToDecStr(factorMin, 4));
tfDetCalFactorMax.setText(Helper.dblToDecStr(factorMax, 4));
tfDetCalOffset.setText(Helper.dblToDecStr(offset, 2));
tfDetCalOffsetMin.setText(Helper.dblToDecStr(offsetMin, 2));
tfDetCalOffsetMax.setText(Helper.dblToDecStr(offsetMax, 2));
Expand Down Expand Up @@ -1437,8 +1467,8 @@ private void copyBestCandidate() {

tfDetCalFactor.setText(Helper.dblToDecStr(individual.getCalibrationFactor() / deParameter.numBins, 4));
tfDetCalOffset.setText(Helper.dblToDecStr(individual.getCalibrationOffset(), 2));
tfExpCharge.setText(Helper.dblToDecStr(individual.getCharge(), 2));
tfDetDE.setText(Helper.dblToDecStr(individual.getResolution(), 2));
tfExpCharge.setText(Helper.dblToDecStr(individual.getCharge(), 4));
tfDetDE.setText(Helper.dblToDecStr(individual.getResolution(), 4));

setExpCharge();
blockEvents = false;
Expand All @@ -1454,7 +1484,7 @@ private void makeGACsFromCurrentSetting() {

private void initComponents() {

this.setTitle("Ruthelde V7.7.0 - 2023_01_19 (C) R. Heller");
this.setTitle("Ruthelde V7.7.1 - 2023_05_16 (C) R. Heller");
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setContentPane(rootPanel);
pack();
Expand Down Expand Up @@ -1632,21 +1662,15 @@ public void focusLost(FocusEvent e) {
blockEvents = false;
});

tfExpChargeMin.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (!blockEvents) {
setExpMinCharge();
}
tfExpChargeMin.addActionListener(e -> {
if (!blockEvents) {
setExpMinCharge();
}
});

tfExpChargeMax.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (!blockEvents) {
setExpMaxCharge();
}
tfExpChargeMax.addActionListener(e -> {
if (!blockEvents) {
setExpMaxCharge();
}
});

Expand Down
70 changes: 43 additions & 27 deletions src/main/java/com/ruthelde/Target/TargetView.form
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.ruthelde.Target.TargetView">
<grid id="27dc6" binding="rootPanel" layout-manager="GridLayoutManager" row-count="5" column-count="6" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="rootPanel" layout-manager="GridLayoutManager" row-count="6" column-count="6" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="5" left="5" bottom="5" right="5"/>
<constraints>
<xy x="20" y="20" width="954" height="457"/>
<xy x="20" y="20" width="954" height="485"/>
</constraints>
<properties/>
<border type="none"/>
Expand Down Expand Up @@ -118,14 +118,6 @@
<text value="Remove"/>
</properties>
</component>
<component id="c3a5a" class="javax.swing.JButton" binding="btnNormalizeElements">
<constraints>
<grid row="4" column="2" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Normalize"/>
</properties>
</component>
<component id="5bdcc" class="javax.swing.JButton" binding="btnAddIsotope">
<constraints>
<grid row="3" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
Expand All @@ -142,22 +134,6 @@
<text value="Remove"/>
</properties>
</component>
<component id="2c12f" class="javax.swing.JButton" binding="btnNormalizeIsotopes">
<constraints>
<grid row="4" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Normalize"/>
</properties>
</component>
<component id="fd361" class="javax.swing.JButton" binding="btnNaturalizeIsotopes">
<constraints>
<grid row="4" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Naturalize"/>
</properties>
</component>
<grid id="3013a" layout-manager="GridLayoutManager" row-count="6" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="5" left="5" bottom="5" right="5"/>
<constraints>
Expand Down Expand Up @@ -444,7 +420,7 @@
</grid>
<component id="a205f" class="javax.swing.JLabel" binding="lblErrorMsg">
<constraints>
<grid row="4" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="5" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value=""/>
Expand All @@ -455,6 +431,46 @@
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="58b8f" class="javax.swing.JButton" binding="btnLayerUp">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Up"/>
</properties>
</component>
<component id="c3a5a" class="javax.swing.JButton" binding="btnNormalizeElements">
<constraints>
<grid row="4" column="2" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Normalize"/>
</properties>
</component>
<component id="2c12f" class="javax.swing.JButton" binding="btnNormalizeIsotopes">
<constraints>
<grid row="4" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Normalize"/>
</properties>
</component>
<component id="fd361" class="javax.swing.JButton" binding="btnNaturalizeIsotopes">
<constraints>
<grid row="4" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Naturalize"/>
</properties>
</component>
<component id="a4883" class="javax.swing.JButton" binding="btnLayerDown">
<constraints>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Down"/>
</properties>
</component>
</children>
</grid>
</form>
Loading

0 comments on commit e9be40c

Please sign in to comment.