Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6b12e7b

Browse filesBrowse files
committed
AbsorptionModel.java: Moved optimisationVector(…) and assign(…) from Problem class
ADIScheme: Increased default time step to ensure adequate results Calculation.java: - Fixed problem with missing parent when creating a Calculation from a SearchTask. In the copy constructor, the parent is now removed, but the result is preserved. - Fixed incorrect status update in setStatus(…) method. Rules have been created to block status update in certain cases. - Introduced the isBetterThan(…) method, which performs a statistical check (e.g. BIC) plus an F-test, if the latter is possible, and uses this combination to assess which calculations gives a better result. CorrelationBuffer.java: truncate(…) excludes buffer elements which show very close parameter values and therefore negatively affect the correlation tests. CorrelationTest: Changed selector for correlation tests Details: Status may now indicate if the the new results are worse than the previous result. DiathermicMedium: Removed custom default number of data points DifferenceScheme: Added a check to see if the DiscretePulse had already been created. If so, the latter is only updated. This prevents adding superfluous listeners and creating objects DiscretePulse: Added Objects.requireNonNull when accessing the SearchTask ancestor of the Problem instance FTest.java: Added the Fischer test capability to compare two Calculation instances where one model is nested within the other. InstanceDescriptor: Instead of returning false in case if the descriptor is not recognised, the attemptUpdate(…) now throws an IllegalArgumentException. NetzschCSVReader: - Added detector spot size in the list of imported properties. -findLineByLabel now uses reader.mark(…) to keep track of previous valid position. If the search fails, the position of the reader will be reset to this mark. ParticipatingMedium & PenetrationProblem: Removed custom number of data points PenetrationProblem: Moved functionality specific to absoprtion model into the AbsorptionModel class PulseMainMenu: Changed initialisation of the correlation tests and communication of the selector with GUI. ResultTable & ResultTableModel: Added null checks for the result extracted from the Calculation instance ResultTableModel: Heavily modified the addRow(result) method where an entry will not be added to the results table if (a) a previous calculation had been previously completed and (b) the new result is rated worse than the previous result. SearchTask: Added storeCalculation(…) and findBestCalculation(…). TaskManager: Added call to storeCalculation(…) in the execute method, upon successful completion of the CompletableFuture.
1 parent 7b9081f commit 6b12e7b
Copy full SHA for 6b12e7b
Expand file treeCollapse file tree

30 files changed

+558
-202
lines changed

‎pom.xml

Copy file name to clipboardExpand all lines: pom.xml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<groupId>kotik-coder</groupId>
55
<artifactId>PULsE</artifactId>
6-
<version>1.93F</version>
6+
<version>1.94</version>
77
<name>PULsE</name>
88
<description>Processing Unit for Laser flash Experiments</description>
99
<developers>

‎src/main/java/pulse/input/Metadata.java

Copy file name to clipboardExpand all lines: src/main/java/pulse/input/Metadata.java
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import pulse.problem.laser.RectangularPulse;
2323
import pulse.properties.NumericProperty;
2424
import pulse.properties.NumericPropertyKeyword;
25+
import static pulse.properties.NumericPropertyKeyword.FOV_OUTER;
2526
import pulse.properties.Property;
2627
import pulse.properties.SampleName;
2728
import pulse.tasks.Identifier;
@@ -199,6 +200,7 @@ public Set<NumericPropertyKeyword> listedKeywords() {
199200
set.add(LASER_ENERGY);
200201
set.add(DETECTOR_GAIN);
201202
set.add(DETECTOR_IRIS);
203+
set.add(FOV_OUTER);
202204
return set;
203205
}
204206

‎src/main/java/pulse/io/readers/NetzschCSVReader.java

Copy file name to clipboardExpand all lines: src/main/java/pulse/io/readers/NetzschCSVReader.java
+25-2Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public class NetzschCSVReader implements CurveReader {
4545
private final static String SHOT_DATA = "Shot_data";
4646
private final static String DETECTOR = "DETECTOR";
4747
private final static String THICKNESS = "Thickness_RT";
48+
private final static String DETECTOR_SPOT_SIZE = "Spotsize";
4849
private final static String DIAMETER = "Diameter";
4950

5051
/**
@@ -109,6 +110,13 @@ public List<ExperimentalData> read(File file) throws IOException {
109110
var format = DecimalFormat.getInstance(locale);
110111
format.setGroupingUsed(false);
111112

113+
var spot = findLineByLabel(reader, DETECTOR_SPOT_SIZE, THICKNESS, delims);
114+
double spotSize = 0;
115+
if(spot != null) {
116+
var spotTokens = spot.split(delims);
117+
spotSize = format.parse(spotTokens[spotTokens.length - 1]).doubleValue() * TO_METRES;
118+
}
119+
112120
var tempTokens = findLineByLabel(reader, THICKNESS, delims).split(delims);
113121

114122
final double thickness = format.parse(tempTokens[tempTokens.length - 1]).doubleValue() * TO_METRES;
@@ -135,7 +143,7 @@ public List<ExperimentalData> read(File file) throws IOException {
135143
var met = new Metadata(derive(TEST_TEMPERATURE, sampleTemperature), shotId);
136144
met.set(NumericPropertyKeyword.THICKNESS, derive(NumericPropertyKeyword.THICKNESS, thickness));
137145
met.set(NumericPropertyKeyword.DIAMETER, derive(NumericPropertyKeyword.DIAMETER, diameter));
138-
met.set(NumericPropertyKeyword.FOV_OUTER, derive(NumericPropertyKeyword.FOV_OUTER, 0.85 * diameter));
146+
met.set(NumericPropertyKeyword.FOV_OUTER, derive(NumericPropertyKeyword.FOV_OUTER, spotSize != 0 ? spotSize : 0.85 * diameter));
139147
met.set(NumericPropertyKeyword.SPOT_DIAMETER, derive(NumericPropertyKeyword.SPOT_DIAMETER, 0.94 * diameter));
140148

141149
curve.setMetadata(met);
@@ -198,29 +206,44 @@ protected static int determineShotID(BufferedReader reader, File file) throws IO
198206
return shotId;
199207

200208
}
201-
209+
202210
protected static String findLineByLabel(BufferedReader reader, String label, String delims) throws IOException {
211+
return findLineByLabel(reader, label, "!!!", delims);
212+
}
213+
214+
protected static String findLineByLabel(BufferedReader reader, String label, String stopLabel, String delims) throws IOException {
203215

204216
String line = "";
205217
String[] tokens;
206218

219+
reader.mark(1000);
220+
207221
//find keyword
208222
outer:
209223
for (line = reader.readLine(); line != null; line = reader.readLine()) {
210224

211225
tokens = line.split(delims);
212226

213227
for (String token : tokens) {
228+
214229
if (token.equalsIgnoreCase(label)) {
215230
break outer;
216231
}
232+
233+
if(token.equalsIgnoreCase(stopLabel)) {
234+
line = null;
235+
reader.reset();
236+
break outer;
237+
}
238+
217239
}
218240

219241
}
220242

221243
return line;
222244

223245
}
246+
224247
/**
225248
* As this class uses the singleton pattern, only one instance is created
226249
* using an empty no-argument constructor.

‎src/main/java/pulse/problem/laser/DiscretePulse.java

Copy file name to clipboardExpand all lines: src/main/java/pulse/problem/laser/DiscretePulse.java
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package pulse.problem.laser;
22

3+
import java.util.Objects;
4+
import pulse.input.ExperimentalData;
35
import pulse.problem.schemes.Grid;
46
import pulse.problem.statements.Problem;
57
import pulse.problem.statements.Pulse;
@@ -37,14 +39,19 @@ public DiscretePulse(Problem problem, Grid grid) {
3739

3840
recalculate();
3941

40-
var data = ((SearchTask) problem.specificAncestor(SearchTask.class)).getExperimentalCurve();
42+
Object ancestor =
43+
Objects.requireNonNull( problem.specificAncestor(SearchTask.class),
44+
"Problem has not been assigned to a SearchTask");
45+
46+
ExperimentalData data = ((SearchTask)ancestor).getExperimentalCurve();
4147

4248
pulse.getPulseShape().init(data, this);
4349
pulse.addListener(e -> {
4450
timeFactor = problem.getProperties().timeFactor();
4551
recalculate();
4652
pulse.getPulseShape().init(data, this);
4753
});
54+
4855
}
4956

5057
/**

‎src/main/java/pulse/problem/schemes/ADIScheme.java

Copy file name to clipboardExpand all lines: src/main/java/pulse/problem/schemes/ADIScheme.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public abstract class ADIScheme extends DifferenceScheme {
1919
* time factor.
2020
*/
2121
public ADIScheme() {
22-
this(derive(GRID_DENSITY, 30), derive(TAU_FACTOR, 1.0));
22+
this(derive(GRID_DENSITY, 30), derive(TAU_FACTOR, 0.5));
2323
}
2424

2525
/**

‎src/main/java/pulse/problem/schemes/DifferenceScheme.java

Copy file name to clipboardExpand all lines: src/main/java/pulse/problem/schemes/DifferenceScheme.java
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ public void copyFrom(DifferenceScheme df) {
108108
* @see pulse.problem.schemes.Grid.adjustTo()
109109
*/
110110
protected void prepare(Problem problem) {
111-
discretePulse = problem.discretePulseOn(grid);
111+
if(discretePulse == null)
112+
discretePulse = problem.discretePulseOn(grid);
113+
else
114+
discretePulse.recalculate();
115+
112116
grid.adjustTo(discretePulse);
113117

114118
var hc = problem.getHeatingCurve();

‎src/main/java/pulse/problem/schemes/solvers/ImplicitTranslucentSolver.java

Copy file name to clipboardExpand all lines: src/main/java/pulse/problem/schemes/solvers/ImplicitTranslucentSolver.java
+7-4Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import pulse.problem.statements.PenetrationProblem;
1212
import pulse.problem.statements.Problem;
1313
import pulse.problem.statements.model.AbsorptionModel;
14+
import pulse.problem.statements.model.BeerLambertAbsorption;
1415
import pulse.properties.NumericProperty;
1516

1617
public class ImplicitTranslucentSolver extends ImplicitScheme implements Solver<PenetrationProblem> {
@@ -44,14 +45,16 @@ private void prepare(PenetrationProblem problem) {
4445

4546
final double Bi1H = (double) problem.getProperties().getHeatLoss().getValue() * grid.getXStep();
4647
final double hx = grid.getXStep();
48+
49+
absorption = problem.getAbsorptionModel();
50+
4751
HH = hx * hx;
4852
_2Bi1HTAU = 2.0 * Bi1H * tau;
4953
b11 = 1.0 / (1.0 + 2.0 * tau / HH * (1 + Bi1H));
5054

51-
absorption = problem.getAbsorptionModel();
5255
final double EPS = 1E-7;
53-
rearAbsorption = tau * absorption.absorption(LASER, (N - EPS) * hx);
54-
frontAbsorption = tau * absorption.absorption(LASER, 0.0);
56+
rearAbsorption = tau * absorption.absorption(LASER, (N - EPS) * hx);
57+
frontAbsorption = tau * absorption.absorption(LASER, 0.0) + 2.0*tau/hx;
5558

5659
var tridiagonal = new TridiagonalMatrixAlgorithm(grid) {
5760

@@ -61,7 +64,7 @@ public double phi(final int i) {
6164
}
6265

6366
};
64-
67+
6568
// coefficients for difference equation
6669
tridiagonal.setCoefA(1. / HH);
6770
tridiagonal.setCoefB(1. / tau + 2. / HH);

‎src/main/java/pulse/problem/statements/DiathermicMedium.java

Copy file name to clipboardExpand all lines: src/main/java/pulse/problem/statements/DiathermicMedium.java
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@
3434
*/
3535
public class DiathermicMedium extends ClassicalProblem {
3636

37-
private final static int DEFAULT_CURVE_POINTS = 300;
3837

3938
public DiathermicMedium() {
4039
super();
41-
getHeatingCurve().setNumPoints(derive(NUMPOINTS, DEFAULT_CURVE_POINTS));
4240
}
4341

4442
public DiathermicMedium(Problem p) {

‎src/main/java/pulse/problem/statements/ParticipatingMedium.java

Copy file name to clipboardExpand all lines: src/main/java/pulse/problem/statements/ParticipatingMedium.java
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,8 @@
2121

2222
public class ParticipatingMedium extends NonlinearProblem {
2323

24-
private final static int DEFAULT_CURVE_POINTS = 300;
25-
2624
public ParticipatingMedium() {
2725
super();
28-
getHeatingCurve().setNumPoints(derive(NUMPOINTS, DEFAULT_CURVE_POINTS));
2926
setComplexity(ProblemComplexity.HIGH);
3027
}
3128

+3-55Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
package pulse.problem.statements;
22

3-
import static pulse.math.transforms.StandardTransformations.LOG;
4-
import static pulse.properties.NumericProperties.derive;
5-
import static pulse.properties.NumericPropertyKeyword.NUMPOINTS;
6-
73
import java.util.List;
84

95
import pulse.math.ParameterVector;
10-
import pulse.math.Segment;
11-
import static pulse.math.transforms.StandardTransformations.ABS;
126
import pulse.problem.schemes.DifferenceScheme;
137
import pulse.problem.schemes.solvers.ImplicitTranslucentSolver;
148
import pulse.problem.schemes.solvers.SolverException;
@@ -21,8 +15,6 @@
2115

2216
public class PenetrationProblem extends ClassicalProblem {
2317

24-
private final static int DEFAULT_CURVE_POINTS = 300;
25-
2618
private InstanceDescriptor<AbsorptionModel> instanceDescriptor
2719
= new InstanceDescriptor<AbsorptionModel>(
2820
"Absorption Model Selector", AbsorptionModel.class);
@@ -31,7 +23,6 @@ public class PenetrationProblem extends ClassicalProblem {
3123

3224
public PenetrationProblem() {
3325
super();
34-
getHeatingCurve().setNumPoints(derive(NUMPOINTS, DEFAULT_CURVE_POINTS));
3526
instanceDescriptor.setSelectedDescriptor(BeerLambertAbsorption.class.getSimpleName());
3627
instanceDescriptor.addListener(() -> initAbsorption());
3728
absorption.setParent(this);
@@ -72,56 +63,13 @@ public InstanceDescriptor<AbsorptionModel> getAbsorptionSelector() {
7263
@Override
7364
public void optimisationVector(ParameterVector output, List<Flag> flags) {
7465
super.optimisationVector(output, flags);
75-
76-
for (int i = 0, size = output.dimension(); i < size; i++) {
77-
var key = output.getIndex(i);
78-
double value = 0;
79-
80-
switch (key) {
81-
case LASER_ABSORPTIVITY:
82-
value = (double) (absorption.getLaserAbsorptivity()).getValue();
83-
break;
84-
case THERMAL_ABSORPTIVITY:
85-
value = (double) (absorption.getThermalAbsorptivity()).getValue();
86-
break;
87-
case COMBINED_ABSORPTIVITY:
88-
value = (double) (absorption.getCombinedAbsorptivity()).getValue();
89-
break;
90-
default:
91-
continue;
92-
}
93-
94-
//do this for the listed key values
95-
output.setTransform(i, ABS);
96-
output.set(i, value);
97-
output.setParameterBounds(i, new Segment(1E-2, 1000.0));
98-
99-
}
100-
66+
absorption.optimisationVector(output, flags);
10167
}
10268

10369
@Override
10470
public void assign(ParameterVector params) throws SolverException {
10571
super.assign(params);
106-
107-
double value;
108-
109-
for (int i = 0, size = params.dimension(); i < size; i++) {
110-
var key = params.getIndex(i);
111-
112-
switch (key) {
113-
case LASER_ABSORPTIVITY:
114-
case THERMAL_ABSORPTIVITY:
115-
case COMBINED_ABSORPTIVITY:
116-
value = params.inverseTransform(i);
117-
break;
118-
default:
119-
continue;
120-
}
121-
122-
absorption.set(key, derive(key, value));
123-
124-
}
72+
absorption.assign(params);
12573
}
12674

12775
@Override
@@ -139,4 +87,4 @@ public Problem copy() {
13987
return new PenetrationProblem(this);
14088
}
14189

142-
}
90+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.