Skip to content

Commit 0f2f95b

Browse files
author
Artem Lunev
committed
1.91FM_01
Better error handling in SearchTask: now instead of freezing on nonsensical values, an exception is thrown by the assign() method in ThermalProperties if the numeric properties in the ParameterVector do not pass the validate() check, and is handled by setting the status of the task to failed and breaking the main loop of the search. Better handling of very small pulses where calculations could previously start with a pulse width = 0 (less than the grid time step) Better calculation of the maximum temperature rise for the heating curves (baseline correction)
1 parent 8fb90b3 commit 0f2f95b

18 files changed

+72
-40
lines changed

pom.xml

Lines 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.91FM</version>
6+
<version>1.91FM_01</version>
77
<name>PULsE</name>
88
<description>Processing Unit for Laser flash Experiments</description>
99
<developers>

src/main/java/pulse/input/ExperimentalData.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ public List<Point2D> runningAverage(int reductionFactor) {
157157

158158
List<Point2D> crudeAverage = new ArrayList<>(count / reductionFactor);
159159

160-
int start = indexRange.getLowerBound();
161-
int end = indexRange.getUpperBound();
160+
int start = indexRange.getLowerBound();
161+
int end = indexRange.getUpperBound();
162162

163163
int step = (end - start) / (count / reductionFactor);
164164
double av = 0;
@@ -193,9 +193,9 @@ public List<Point2D> runningAverage(int reductionFactor) {
193193
* @see pulse.problem.statements.Problem.estimateSignalRange(ExperimentalData)
194194
*/
195195

196-
public double maxAdjustedSignal() {
196+
public Point2D maxAdjustedSignal() {
197197
var degraded = runningAverage(REDUCTION_FACTOR);
198-
return (max(degraded, pointComparator)).getY();
198+
return max(degraded, pointComparator);
199199
}
200200

201201
/**
@@ -217,18 +217,14 @@ public double maxAdjustedSignal() {
217217
*/
218218

219219
public double halfRiseTime() {
220-
var degraded = runningAverage(REDUCTION_FACTOR);
221-
double max = (max(degraded, pointComparator)).getY();
222-
var baseline = new FlatBaseline();
220+
var degraded = runningAverage(REDUCTION_FACTOR);
221+
var max = (max(degraded, pointComparator));
222+
var baseline = new FlatBaseline();
223223
baseline.fitTo(this);
224224

225-
double halfMax = (max + baseline.valueAt(0)) / 2.0;
226-
227-
int cutoffIndex = degraded.size() - 1;
228-
229-
for(int i = cutoffIndex; i > 0 && degraded.get(i).getY() < halfMax; i--)
230-
cutoffIndex--;
225+
double halfMax = (max.getY() + baseline.valueAt(0)) / 2.0;
231226

227+
int cutoffIndex = degraded.indexOf(max);
232228
degraded = degraded.subList(0, cutoffIndex);
233229

234230
int index = IndexRange.closestLeft(halfMax,

src/main/java/pulse/math/ParameterVector.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import pulse.math.linear.Vector;
77
import pulse.math.transforms.Transformable;
8+
import pulse.properties.NumericProperties;
89
import pulse.properties.NumericPropertyKeyword;
910

1011
/**
@@ -214,6 +215,15 @@ public String toString() {
214215
sb.append(" Values: " + super.toString());
215216
return sb.toString();
216217
}
218+
219+
public boolean validate() {
220+
for(int i = 0; i < this.dimension(); i++) {
221+
if( !NumericProperties.derive(this.getIndex(i), inverseTransform(i)).validate() ) {
222+
return false;
223+
}
224+
}
225+
return true;
226+
}
217227

218228
public Segment[] getBounds() {
219229
return bounds;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public double laserPowerAt(double time) {
7070

7171
public void recalculate() {
7272
final double width = ((Number) pulse.getPulseWidth().getValue()).doubleValue();
73-
discretePulseWidth = grid.gridTime(width, timeFactor);
73+
discretePulseWidth = Math.max( grid.gridTime(width, timeFactor), grid.getTimeStep() );
7474
}
7575

7676
/**

src/main/java/pulse/problem/schemes/solvers/ImplicitLinearisedSolver.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ public double evalRightBoundary(final int m, final double alphaN, final double b
116116
return (HH * getPreviousSolution()[N] + 2. * tau * betaN) / (2 * Bi1HTAU + HH - 2. * tau * (alphaN - 1));
117117
}
118118

119+
119120
@Override
120121
public DifferenceScheme copy() {
121122
var grid = getGrid();

src/main/java/pulse/problem/statements/ClassicalProblem2D.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import pulse.problem.schemes.DifferenceScheme;
1515
import pulse.problem.schemes.Grid;
1616
import pulse.problem.schemes.Grid2D;
17+
import pulse.problem.schemes.solvers.SolverException;
1718
import pulse.problem.statements.model.ExtendedThermalProperties;
1819
import pulse.problem.statements.model.ThermalProperties;
1920
import pulse.properties.Flag;
@@ -102,7 +103,7 @@ public void optimisationVector(ParameterVector output, List<Flag> flags) {
102103
}
103104

104105
@Override
105-
public void assign(ParameterVector params) {
106+
public void assign(ParameterVector params) throws SolverException {
106107
super.assign(params);
107108
var properties = (ExtendedThermalProperties) getProperties();
108109

src/main/java/pulse/problem/statements/CoreShellProblem.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import pulse.math.transforms.InvDiamTransform;
1515
import pulse.math.transforms.InvLenSqTransform;
1616
import pulse.math.transforms.InvLenTransform;
17+
import pulse.problem.schemes.solvers.SolverException;
1718
import pulse.problem.statements.model.ExtendedThermalProperties;
1819
import pulse.properties.Flag;
1920
import pulse.properties.NumericProperty;
@@ -139,7 +140,7 @@ public void optimisationVector(ParameterVector output, List<Flag> flags) {
139140
}
140141

141142
@Override
142-
public void assign(ParameterVector params) {
143+
public void assign(ParameterVector params) throws SolverException {
143144
super.assign(params);
144145

145146
for (int i = 0, size = params.dimension(); i < size; i++) {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import pulse.math.transforms.AtanhTransform;
1212
import pulse.problem.schemes.DifferenceScheme;
1313
import pulse.problem.schemes.solvers.ImplicitDiathermicSolver;
14+
import pulse.problem.schemes.solvers.SolverException;
1415
import pulse.problem.statements.model.DiathermicProperties;
1516
import pulse.problem.statements.model.ThermalProperties;
1617
import pulse.properties.Flag;
@@ -80,7 +81,7 @@ public void optimisationVector(ParameterVector output, List<Flag> flags) {
8081
}
8182

8283
@Override
83-
public void assign(ParameterVector params) {
84+
public void assign(ParameterVector params) throws SolverException {
8485
super.assign(params);
8586
var properties = (DiathermicProperties) this.getProperties();
8687

src/main/java/pulse/problem/statements/NonlinearProblem.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import pulse.math.transforms.AtanhTransform;
1818
import pulse.problem.schemes.DifferenceScheme;
1919
import pulse.problem.schemes.ImplicitScheme;
20+
import pulse.problem.schemes.solvers.SolverException;
2021
import pulse.properties.Flag;
2122
import pulse.properties.NumericProperty;
2223
import pulse.properties.Property;
@@ -96,11 +97,12 @@ public void optimisationVector(ParameterVector output, List<Flag> flags) {
9697
*
9798
* @param params the optimisation vector, containing a similar set of parameters
9899
* to this {@code Problem}
100+
* @throws SolverException
99101
* @see listedTypes()
100102
*/
101103

102104
@Override
103-
public void assign(ParameterVector params) {
105+
public void assign(ParameterVector params) throws SolverException {
104106
super.assign(params);
105107
var p = getProperties();
106108

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import pulse.math.transforms.Transformable;
1313
import pulse.problem.schemes.DifferenceScheme;
1414
import pulse.problem.schemes.solvers.MixedCoupledSolver;
15+
import pulse.problem.schemes.solvers.SolverException;
1516
import pulse.problem.statements.model.ThermalProperties;
1617
import pulse.problem.statements.model.ThermoOpticalProperties;
1718
import pulse.properties.Flag;
@@ -85,7 +86,7 @@ public void optimisationVector(ParameterVector output, List<Flag> flags) {
8586
}
8687

8788
@Override
88-
public void assign(ParameterVector params) {
89+
public void assign(ParameterVector params) throws SolverException {
8990
super.assign(params);
9091
var properties = (ThermoOpticalProperties)getProperties();
9192

0 commit comments

Comments
 (0)