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 64680d7

Browse filesBrowse files
committed
PULsE v1.94
#ParameterVector.java -Changed findMalformedElements to conform with the transforms defined by the class instance and simplified the method calls. #Solver implementations and subclasses of DifferenceScheme: -Enabled throwing SolverException in solve(), timeStep() and iteration() #ThermalProperties.java -Introduced findMalformedProperties() for automated property validation -Fixed an error with density and heat capacity values not being assigned to the corresponding variables in fill() - Fixed a caveat in the calculateEmissivity() method where, in some extreme cases, the emissivity values could be greater than unity or smaller than zero, which led to critical breakdown of radiative transfer calculations. - Created a toString() method with a formatted output of the thermal properties. #CoupledImplicitScheme.java -Added missing call to super method FixedPointIterations.super.finaliseIteration() -Added a throws SolverException line in setCalculationStatus(…) when the status is not NORMAL #Status.java -Added optional message to further customise the status updates. The message is accessible via getDetailedMessage() #ExplicitLinearisedSolver.java, ImplicitLinearisedSolver.java -Experimental feature: rear-surface heat source introduced through the ‘zeta’ factor. This slightly changes the right boundary expressions and the timeStep(…) method #RTECalculationStatus.java -Added a new status, ‘INVALID_FLUXES’, which indicates the RTE calculation resulted in invalid flux values. #StateEntry.java -In case of a Status having a non-empty detailed message, the message will be printed in the toString() method, which has been modified accordingly #ParticipatingMedium.java -Changed bounds for the parameters, including e.g. the Planck number and optical thickness -Replaced all transforms for all optical parameters to StickTransform. This has proven to be more fail-proof #ClassicalProblem.java -Introduced the bias property, which refers to the bias in the source power between the front and rear surfaces #Problem.java -Added ABS transformation for the MAXTEMP property in optimisationVector() -Added parameter bounds for the HEAT_LOSS property, linking them to the parameter bounds retrieved from the XML file -Removed unnecessary method calls and conditional statement in setHeatLossParameter() -Added check for malformed property values in assign(…). This is expected to be called by all subclasses of Problem #NonlinearProblem.java -Emissivity is now calculated following every call to assign(…), not just for selected properties #RadiativeTransferSolver.java -Added flux.init() call in init(…), when fluxes are not null #FixedPointIterations.java -Added check for malformed temperature value array. This checks for non-finite elements or sum of elements exceeding a maximum threshold and throws a SolverException #ExplicitCoupledSolver, ImplicitCoupledSolver, MixedCoupledSolver -Improved exception handling and monitoring of calculation health #IndexRange.java - Fixed an erratic statement in the closest(…) method where an exception would be thrown when sizeMinusOne were less than 1 #Fluxes.java - Added checkArrays() method, which checks whether the fluxes are finite - Introduced an overridable init() method #FluxesAndExplicitDerivatives.java - Instead of having an overriden setDensity() method, the latter is set final, with the init() method now overriding superclass method - Introduced #ThermoOpticalProperties - New overriden toString() method that outputs all thermo-optical properties #ExperimentalData - Changed MAX_REDUCTION_FACTOR to 256 - Changed calculateHalfTime(), where the running-average curve would be calculated iteratively changing the reduction factor until certain conditions are met #SearchTask.java - Added null check in addListeners(…) - run() in several places: replaced confusing System.err on SolverException by a detailed status update with the notifyFailedStatus(…) call #DifferenceScheme.java - Important change to runTimeSequence(…), where, after filling the solution curve array, the nominal number of points is replaced by the real number of points, should that number be smaller than the former. #Launcher.java - Added file lock to prevent launching multiple instances of PULsE simultaneously #NonlinearProblem.java - Added LASER_ENERGY as a possible search variable #LMOptimiser.java - Added check for malformed parameter vectors and gradient vectors, causing a SolverException to be thrown if found #Calculation.java - process() will first check for malformed properties before proceeding with the calculation #Details.java - added SOLVER_ERROR #NumericProperties.java - added checks for non-finite values in isValueSensible(...) #Other classes: Made some getter and setter methods final to improve encapsulation
1 parent 6b12e7b commit 64680d7
Copy full SHA for 64680d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

51 files changed

+568
-317
lines changed

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

Copy file name to clipboardExpand all lines: src/main/java/pulse/input/ExperimentalData.java
+20-10Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import java.util.ArrayList;
1313
import java.util.Comparator;
1414
import java.util.List;
15-
import java.util.Optional;
1615
import java.util.stream.Collectors;
1716

1817
import pulse.AbstractData;
@@ -53,11 +52,13 @@ public class ExperimentalData extends AbstractData {
5352
* Scientific Instruments, 91(6), 064902.
5453
*/
5554
public final static int REDUCTION_FACTOR = 32;
55+
56+
public final static int MAX_REDUCTION_FACTOR = 256;
5657

5758
/**
5859
* A fail-safe factor.
5960
*/
60-
public final static double FAIL_SAFE_FACTOR = 3.0;
61+
public final static double FAIL_SAFE_FACTOR = 10.0;
6162

6263
private static Comparator<Point2D> pointComparator = (p1, p2) -> valueOf(p1.getY()).compareTo(valueOf(p2.getY()));
6364

@@ -217,19 +218,28 @@ public Point2D maxAdjustedSignal() {
217218
* @see getHalfTime()
218219
*/
219220
public void calculateHalfTime() {
220-
var degraded = runningAverage(REDUCTION_FACTOR);
221-
var max = (max(degraded, pointComparator));
222221
var baseline = new FlatBaseline();
223222
baseline.fitTo(this);
224-
225-
double halfMax = (max.getY() + baseline.valueAt(0)) / 2.0;
226-
227-
int cutoffIndex = degraded.indexOf(max);
223+
224+
int curRedFactor = REDUCTION_FACTOR/2; // reduced twofold since first operation
225+
// in the while loop will increase it likewise
226+
int cutoffIndex = 0;
227+
List<Point2D> degraded = null; //running average
228+
Point2D max = null;
229+
230+
do {
231+
curRedFactor *= 2;
232+
degraded = runningAverage(curRedFactor);
233+
max = (max(degraded, pointComparator));
234+
cutoffIndex = degraded.indexOf(max);
235+
} while(cutoffIndex < 1 && curRedFactor < MAX_REDUCTION_FACTOR);
236+
237+
double halfMax = (max.getY() + baseline.valueAt(0)) / 2.0;
228238
degraded = degraded.subList(0, cutoffIndex);
229-
239+
230240
int index = IndexRange.closestLeft(halfMax,
231241
degraded.stream().map(point -> point.getY()).collect(Collectors.toList()));
232-
242+
233243
if (index < 1) {
234244
System.err.println(Messages.getString("ExperimentalData.HalfRiseError"));
235245
halfTime = max(getTimeSequence()) / FAIL_SAFE_FACTOR;

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

Copy file name to clipboardExpand all lines: src/main/java/pulse/input/IndexRange.java
+18-11Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -186,24 +186,31 @@ public static int closestRight(double of, List<Double> in) {
186186
}
187187

188188
private static int closest(double of, List<Double> in, boolean reverseOrder) {
189-
int sizeMinusOne = Math.max( in.size() - 1, 0); //has to be non-negative
190-
191-
if (of > in.get(sizeMinusOne)) {
192-
return sizeMinusOne;
193-
}
189+
int sizeMinusOne = in.size() - 1; //has to be non-negative
190+
191+
int result = 0;
192+
193+
if (sizeMinusOne < 1) {
194+
result = 0;
195+
} else if (of > in.get(sizeMinusOne)) {
196+
result = sizeMinusOne;
197+
} else {
198+
199+
int start = reverseOrder ? sizeMinusOne - 1 : 0;
200+
int increment = reverseOrder ? -1 : 1;
194201

195-
int start = reverseOrder ? sizeMinusOne - 1 : 0;
196-
int increment = reverseOrder ? -1 : 1;
202+
for (int i = start; reverseOrder ? (i > -1) : (i < sizeMinusOne); i += increment) {
197203

198-
for (int i = start; reverseOrder ? (i > -1) : (i < sizeMinusOne); i += increment) {
204+
if (between(of, in.get(i), in.get(i + 1))) {
205+
result = i;
206+
break;
207+
}
199208

200-
if (between(of, in.get(i), in.get(i + 1))) {
201-
return i;
202209
}
203210

204211
}
205212

206-
return 0;
213+
return result;
207214

208215
}
209216

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

Copy file name to clipboardExpand all lines: src/main/java/pulse/input/InterpolationDataset.java
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ public InterpolationDataset() {
5252
*/
5353
public double interpolateAt(double key) {
5454
return interpolation.value(key);
55-
5655
}
5756

5857
/**

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

Copy file name to clipboardExpand all lines: src/main/java/pulse/io/readers/NetzschCSVReader.java
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import java.io.FileReader;
99
import java.io.IOException;
1010
import java.text.DecimalFormat;
11-
import java.text.NumberFormat;
1211
import java.text.ParseException;
1312
import java.util.ArrayList;
1413
import java.util.Arrays;

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

Copy file name to clipboardExpand all lines: src/main/java/pulse/math/ParameterVector.java
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,8 @@ public List<NumericProperty> findMalformedElements() {
236236
var list = new ArrayList<NumericProperty>();
237237

238238
for (int i = 0; i < dimension(); i++) {
239-
var property = def(getIndex(i));
240-
boolean sensible = NumericProperties.isValueSensible(property, get(i));
241-
if (!sensible) {
239+
var property = NumericProperties.derive(getIndex(i), inverseTransform(i));
240+
if (!property.validate()) {
242241
list.add(property);
243242
}
244243
}

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

Copy file name to clipboardExpand all lines: src/main/java/pulse/problem/schemes/CoupledImplicitScheme.java
+12-9Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@
44
import static pulse.properties.NumericProperties.derive;
55
import static pulse.properties.NumericPropertyKeyword.NONLINEAR_PRECISION;
66

7-
import java.util.List;
87
import java.util.Set;
98

109
import pulse.problem.schemes.rte.RTECalculationStatus;
10+
import pulse.problem.schemes.solvers.SolverException;
1111
import pulse.problem.statements.ParticipatingMedium;
1212
import pulse.problem.statements.Problem;
1313
import pulse.properties.NumericProperty;
1414
import pulse.properties.NumericPropertyKeyword;
15-
import static pulse.properties.NumericPropertyKeyword.BASELINE_INTERCEPT;
16-
import pulse.properties.Property;
1715

1816
public abstract class CoupledImplicitScheme extends ImplicitScheme implements FixedPointIterations {
1917

@@ -37,31 +35,34 @@ public CoupledImplicitScheme(NumericProperty N, NumericProperty timeFactor, Nume
3735
}
3836

3937
@Override
40-
public void timeStep(final int m) {
38+
public void timeStep(final int m) throws SolverException {
4139
pls = pulse(m);
4240
doIterations(getCurrentSolution(), nonlinearPrecision, m);
4341
}
4442

4543
@Override
46-
public void iteration(final int m) {
44+
public void iteration(final int m) throws SolverException {
4745
super.timeStep(m);
4846
}
4947

50-
public void finaliseIteration(double[] V) {
48+
@Override
49+
public void finaliseIteration(double[] V) throws SolverException {
50+
FixedPointIterations.super.finaliseIteration(V);
51+
var rte = coupling.getRadiativeTransferEquation();
5152
setCalculationStatus(coupling.getRadiativeTransferEquation().compute(V));
5253
}
5354

5455
public RadiativeTransferCoupling getCoupling() {
5556
return coupling;
5657
}
5758

58-
public void setCoupling(RadiativeTransferCoupling coupling) {
59+
public final void setCoupling(RadiativeTransferCoupling coupling) {
5960
this.coupling = coupling;
6061
this.coupling.setParent(this);
6162
}
6263

6364
@Override
64-
public void finaliseStep() {
65+
public void finaliseStep() throws SolverException {
6566
super.finaliseStep();
6667
coupling.getRadiativeTransferEquation().getFluxes().store();
6768
}
@@ -104,8 +105,10 @@ public RTECalculationStatus getCalculationStatus() {
104105
return calculationStatus;
105106
}
106107

107-
public void setCalculationStatus(RTECalculationStatus calculationStatus) {
108+
public void setCalculationStatus(RTECalculationStatus calculationStatus) throws SolverException {
108109
this.calculationStatus = calculationStatus;
110+
if(calculationStatus != RTECalculationStatus.NORMAL)
111+
throw new SolverException(calculationStatus.toString());
109112
}
110113

111114
public double getCurrentPulseValue() {

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

Copy file name to clipboardExpand all lines: src/main/java/pulse/problem/schemes/DifferenceScheme.java
+26-21Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@
55
import static pulse.properties.NumericProperty.requireType;
66
import static pulse.properties.NumericPropertyKeyword.TIME_LIMIT;
77

8-
import java.util.ArrayList;
9-
import java.util.List;
108
import java.util.Set;
119

1210
import pulse.problem.laser.DiscretePulse;
11+
import pulse.problem.schemes.solvers.SolverException;
1312
import pulse.problem.statements.Problem;
1413
import pulse.properties.NumericProperty;
1514
import pulse.properties.NumericPropertyKeyword;
16-
import static pulse.properties.NumericPropertyKeyword.NONLINEAR_PRECISION;
17-
import pulse.properties.Property;
15+
import static pulse.properties.NumericPropertyKeyword.NUMPOINTS;
1816
import pulse.util.PropertyHolder;
1917
import pulse.util.Reflexive;
2018

@@ -119,16 +117,14 @@ protected void prepare(Problem problem) {
119117
hc.clear();
120118
}
121119

122-
public void runTimeSequence(Problem problem) {
120+
public void runTimeSequence(Problem problem) throws SolverException {
123121
runTimeSequence(problem, 0, timeLimit);
124122
var curve = problem.getHeatingCurve();
125123
final double maxTemp = (double) problem.getProperties().getMaximumTemperature().getValue();
126124
curve.scale(maxTemp / curve.apparentMaximum());
127125
}
128126

129-
public void runTimeSequence(Problem problem, final double offset, final double endTime) {
130-
final var grid = getGrid();
131-
127+
public void runTimeSequence(Problem problem, final double offset, final double endTime) throws SolverException {
132128
var curve = problem.getHeatingCurve();
133129

134130
int adjustedNumPoints = (int) curve.getNumPoints().getValue();
@@ -137,7 +133,7 @@ public void runTimeSequence(Problem problem, final double offset, final double e
137133
final double timeSegment = (endTime - startTime - offset) / problem.getProperties().timeFactor();
138134
final double tau = grid.getTimeStep();
139135

140-
for (double dt = 0, factor = 1.0; dt < tau; adjustedNumPoints *= factor) {
136+
for (double dt = 0, factor; dt < tau; adjustedNumPoints *= factor) {
141137
dt = timeSegment / (adjustedNumPoints - 1);
142138
factor = dt / tau;
143139
timeInterval = (int) factor;
@@ -164,10 +160,19 @@ public void runTimeSequence(Problem problem, final double offset, final double e
164160
curve.addPoint(nextTime, signal());
165161

166162
}
163+
164+
/**
165+
* If the total number of points added by the procedure
166+
* is actually less than the pre-set number of points -- change that number
167+
*/
168+
169+
if(curve.actualNumPoints() < (int)curve.getNumPoints().getValue()) {
170+
curve.setNumPoints(derive(NUMPOINTS, curve.actualNumPoints()));
171+
}
167172

168173
}
169174

170-
private void timeSegment(final int m1, final int m2) {
175+
private void timeSegment(final int m1, final int m2) throws SolverException {
171176
for (int m = m1; m < m2 && normalOperation(); m++) {
172177
timeStep(m);
173178
finaliseStep();
@@ -180,9 +185,9 @@ public double pulse(final int m) {
180185

181186
public abstract double signal();
182187

183-
public abstract void timeStep(final int m);
188+
public abstract void timeStep(final int m) throws SolverException;
184189

185-
public abstract void finaliseStep();
190+
public abstract void finaliseStep() throws SolverException;
186191

187192
public boolean normalOperation() {
188193
return true;
@@ -209,7 +214,7 @@ public String toString() {
209214
* @return the discrete pulse
210215
* @see pulse.problem.statements.Pulse
211216
*/
212-
public DiscretePulse getDiscretePulse() {
217+
public final DiscretePulse getDiscretePulse() {
213218
return discretePulse;
214219
}
215220

@@ -219,7 +224,7 @@ public DiscretePulse getDiscretePulse() {
219224
*
220225
* @return the grid
221226
*/
222-
public Grid getGrid() {
227+
public final Grid getGrid() {
223228
return grid;
224229
}
225230

@@ -228,7 +233,7 @@ public Grid getGrid() {
228233
*
229234
* @param grid the grid
230235
*/
231-
public void setGrid(Grid grid) {
236+
public final void setGrid(Grid grid) {
232237
this.grid = grid;
233238
this.grid.setParent(this);
234239
}
@@ -240,7 +245,7 @@ public void setGrid(Grid grid) {
240245
*
241246
* @return the time interval
242247
*/
243-
public int getTimeInterval() {
248+
public final int getTimeInterval() {
244249
return timeInterval;
245250
}
246251

@@ -249,7 +254,7 @@ public int getTimeInterval() {
249254
*
250255
* @param timeInterval a positive integer.
251256
*/
252-
public void setTimeInterval(int timeInterval) {
257+
public final void setTimeInterval(int timeInterval) {
253258
this.timeInterval = timeInterval;
254259
}
255260

@@ -259,7 +264,7 @@ public void setTimeInterval(int timeInterval) {
259264
* need to be displayed.
260265
*/
261266
@Override
262-
public boolean areDetailsHidden() {
267+
public final boolean areDetailsHidden() {
263268
return hideDetailedAdjustment;
264269
}
265270

@@ -269,7 +274,7 @@ public boolean areDetailsHidden() {
269274
*
270275
* @param b a boolean.
271276
*/
272-
public static void setDetailsHidden(boolean b) {
277+
public final static void setDetailsHidden(boolean b) {
273278
hideDetailedAdjustment = b;
274279
}
275280

@@ -281,7 +286,7 @@ public static void setDetailsHidden(boolean b) {
281286
* @return the {@code NumericProperty} with the type {@code TIME_LIMIT}
282287
* @see pulse.properties.NumericPropertyKeyword
283288
*/
284-
public NumericProperty getTimeLimit() {
289+
public final NumericProperty getTimeLimit() {
285290
return derive(TIME_LIMIT, timeLimit);
286291
}
287292

@@ -294,7 +299,7 @@ public NumericProperty getTimeLimit() {
294299
* {@code TIME_LIMIT}
295300
* @see pulse.properties.NumericPropertyKeyword
296301
*/
297-
public void setTimeLimit(NumericProperty timeLimit) {
302+
public final void setTimeLimit(NumericProperty timeLimit) {
298303
requireType(timeLimit, TIME_LIMIT);
299304
this.timeLimit = (double) timeLimit.getValue();
300305
firePropertyChanged(this, timeLimit);

0 commit comments

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