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 1ce1f8e

Browse filesBrowse files
committed
Minor Fixes
- Fixed pulse visualisation. Now it takes parameters directly from the PulseShape, which is initialised by the DiscretePulse. Moreover, it only plots points at discrete time steps defined by the Grid. Therefore, the user should have an idea as to how detailed the pulse correction is. - Adjusted the pulse resolution allowed for 2D models. This had to be done since 2D calculations are more demanding in terms of the number of pulse points. Previously these resulted in incorrect Tinf values.
1 parent ac55016 commit 1ce1f8e
Copy full SHA for 1ce1f8e

File tree

Expand file treeCollapse file tree

7 files changed

+88
-48
lines changed
Filter options
Expand file treeCollapse file tree

7 files changed

+88
-48
lines changed

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

Copy file name to clipboardExpand all lines: src/main/java/pulse/problem/laser/DiscretePulse.java
+22-9Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import pulse.problem.schemes.Grid;
88
import pulse.problem.statements.Problem;
99
import pulse.problem.statements.Pulse;
10+
import static pulse.properties.NumericProperties.derive;
11+
import static pulse.properties.NumericPropertyKeyword.PULSE_WIDTH;
1012
import pulse.tasks.SearchTask;
1113

1214
/**
@@ -34,7 +36,7 @@ public class DiscretePulse {
3436
* <i>t</i><sub>c</sub>
3537
* is the time factor defined in the {@code Problem} class.
3638
*/
37-
public final static int WIDTH_TOLERANCE_FACTOR = 1000;
39+
private final static int WIDTH_TOLERANCE_FACTOR = 1000;
3840

3941
/**
4042
* This creates a one-dimensional discrete pulse on a {@code grid}.
@@ -74,7 +76,7 @@ private void init(ExperimentalData data) {
7476
widthOnGrid = 0;
7577
recalculate();
7678
pulse.getPulseShape().init(data, this);
77-
normalise();
79+
invTotalEnergy = 1.0/totalEnergy();
7880
}
7981

8082
/**
@@ -96,7 +98,7 @@ public double laserPowerAt(double time) {
9698
*/
9799
public final void recalculate() {
98100
final double nominalWidth = ((Number) pulse.getPulseWidth().getValue()).doubleValue();
99-
final double resolvedWidth = timeConversionFactor / WIDTH_TOLERANCE_FACTOR;
101+
final double resolvedWidth = timeConversionFactor / getWidthToleranceFactor();
100102

101103
final double EPS = 1E-10;
102104

@@ -112,19 +114,20 @@ public final void recalculate() {
112114
//change pulse width
113115
setDiscreteWidth(resolvedWidth);
114116
shape.init(null, this);
117+
//adjust the pulse object to update the visualised pulse
115118
} else if(nominalWidth > resolvedWidth + EPS) {
116119
setDiscreteWidth(nominalWidth);
117120
}
118121

119122
}
120123

121124
/**
122-
* Calculates the total pulse energy using a numerical integrator. The
125+
* Calculates the total pulse energy using a numerical integrator.The
123126
* normalisation factor is then equal to the inverse total energy.
127+
* @return the total pulse energy, assuming sample area fully covered by the beam
124128
*/
125129

126-
public final void normalise() {
127-
invTotalEnergy = 1.0;
130+
public final double totalEnergy() {
128131
var pulseShape = pulse.getPulseShape();
129132

130133
var integrator = new MidpointIntegrator(new Segment(0, widthOnGrid)) {
@@ -136,8 +139,7 @@ public double integrand(double... vars) {
136139

137140
};
138141

139-
invTotalEnergy = 1.0 / integrator.integrate();
140-
142+
return integrator.integrate();
141143
}
142144

143145
/**
@@ -191,7 +193,18 @@ public double getConversionFactor() {
191193
*/
192194

193195
public double resolvedPulseWidth() {
194-
return timeConversionFactor / WIDTH_TOLERANCE_FACTOR;
196+
return timeConversionFactor / getWidthToleranceFactor();
197+
}
198+
199+
/**
200+
* Assuming a characteristic time is divided by the return value of this method
201+
* and is set to the minimal resolved pulse width, shows how small a pulse width
202+
* can be to enable finite pulse correction.
203+
* @return the smallest fraction of a characteristic time resolved as a finite pulse.
204+
*/
205+
206+
public int getWidthToleranceFactor() {
207+
return WIDTH_TOLERANCE_FACTOR;
195208
}
196209

197210
}

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

Copy file name to clipboardExpand all lines: src/main/java/pulse/problem/laser/DiscretePulse2D.java
+42-12Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@
1919
public class DiscretePulse2D extends DiscretePulse {
2020

2121
private double discretePulseSpot;
22-
private double radialFactor;
22+
private double sampleRadius;
23+
private double normFactor;
24+
25+
/**
26+
* This had to be decreased for the 2d pulses.
27+
*/
28+
29+
private final static int WIDTH_TOLERANCE_FACTOR = 200;
2330

2431
/**
2532
* The constructor for {@code DiscretePulse2D}.
@@ -35,9 +42,8 @@ public class DiscretePulse2D extends DiscretePulse {
3542
public DiscretePulse2D(ClassicalProblem2D problem, Grid2D grid) {
3643
super(problem, grid);
3744
var properties = (ExtendedThermalProperties) problem.getProperties();
38-
init(properties);
39-
40-
properties.addListener(e -> init(properties) );
45+
calcPulseSpot(properties);
46+
properties.addListener(e -> calcPulseSpot(properties) );
4147
}
4248

4349
/**
@@ -47,20 +53,34 @@ public DiscretePulse2D(ClassicalProblem2D problem, Grid2D grid) {
4753
* It uses a Heaviside function to determine whether the {@code radialCoord}
4854
* lies within the {@code 0 <= radialCoord <= discretePulseSpot} interval.
4955
* It uses the {@code time} parameter to determine the discrete pulse
50-
* function using {@code evaluateAt(time)}.
56+
* function using {@code evaluateAt(time)}. </p>
5157
*
5258
* @param time the time for calculation
5359
* @param radialCoord - the radial coordinate [length dimension]
5460
* @return the pulse function at {@code time} and {@code coord}, or 0 if
5561
* {@code coord > spotDiameter}.
5662
* @see pulse.problem.laser.PulseTemporalShape.laserPowerAt(double)
5763
*/
64+
5865
public double evaluateAt(double time, double radialCoord) {
59-
return laserPowerAt(time) * (0.5 + 0.5 * signum(discretePulseSpot - radialCoord));
66+
return laserPowerAt(time)
67+
* (0.5 + 0.5 * signum(discretePulseSpot - radialCoord));
6068
}
6169

62-
private void init(ExtendedThermalProperties properties) {
63-
radialFactor = (double) properties.getSampleDiameter().getValue() / 2.0;
70+
/**
71+
* Calculates the laser power at a give moment in time. The total laser
72+
* energy is normalised over a beam partially illuminating the sample surface.
73+
* @param time a moment in time (in dimensionless units)
74+
* @return the laser power in arbitrary units
75+
*/
76+
77+
@Override
78+
public double laserPowerAt(double time) {
79+
return normFactor * super.laserPowerAt(time);
80+
}
81+
82+
private void calcPulseSpot(ExtendedThermalProperties properties) {
83+
sampleRadius = (double) properties.getSampleDiameter().getValue() / 2.0;
6484
evalPulseSpot();
6585
}
6686

@@ -72,17 +92,27 @@ private void init(ExtendedThermalProperties properties) {
7292
public final void evalPulseSpot() {
7393
var pulse = (Pulse2D) getPulse();
7494
var grid2d = (Grid2D) getGrid();
75-
final double radius = (double) pulse.getSpotDiameter().getValue() / 2.0;
76-
discretePulseSpot = grid2d.gridRadialDistance(radius, radialFactor);
95+
final double spotRadius = (double) pulse.getSpotDiameter().getValue() / 2.0;
96+
discretePulseSpot = grid2d.gridRadialDistance(spotRadius, sampleRadius);
7797
grid2d.adjustStepSize(this);
98+
normFactor = sampleRadius * sampleRadius / spotRadius / spotRadius;
7899
}
79100

80101
public final double getDiscretePulseSpot() {
81102
return discretePulseSpot;
82103
}
83104

84105
public final double getRadialConversionFactor() {
85-
return radialFactor;
106+
return sampleRadius;
107+
}
108+
109+
/**
110+
* A smaller tolerance factor is set for 2D calculations
111+
*/
112+
113+
@Override
114+
public int getWidthToleranceFactor() {
115+
return WIDTH_TOLERANCE_FACTOR;
86116
}
87117

88-
}
118+
}

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

Copy file name to clipboardExpand all lines: src/main/java/pulse/problem/statements/ClassicalProblem2D.java
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ public String toString() {
6767
public DiscretePulse discretePulseOn(Grid grid) {
6868
return grid instanceof Grid2D ? new DiscretePulse2D(this, (Grid2D) grid) : super.discretePulseOn(grid);
6969
}
70-
7170

7271
@Override
7372
public void optimisationVector(ParameterVector output, List<Flag> flags) {

‎src/main/java/pulse/ui/components/PulseChart.java

Copy file name to clipboardExpand all lines: src/main/java/pulse/ui/components/PulseChart.java
+18-21Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222

2323
import pulse.problem.statements.Problem;
2424
import pulse.problem.statements.Pulse;
25+
import pulse.tasks.Calculation;
2526

26-
public class PulseChart extends AuxPlotter<Pulse> {
27+
public class PulseChart extends AuxPlotter<Calculation> {
2728

28-
private final static int NUM_PULSE_POINTS = 600;
2929
private final static double TO_MILLIS = 1E3;
3030

3131
public PulseChart(String xLabel, String yLabel) {
@@ -59,36 +59,33 @@ private void setLegendTitle() {
5959
}
6060

6161
@Override
62-
public void plot(Pulse pulse) {
63-
requireNonNull(pulse);
62+
public void plot(Calculation c) {
63+
requireNonNull(c);
64+
65+
Problem problem = c.getProblem();
6466

65-
var problem = (Problem) pulse.getParent();
6667
double startTime = (double) problem.getHeatingCurve().getTimeShift().getValue();
6768

6869
var pulseDataset = new XYSeriesCollection();
69-
pulseDataset.addSeries(series(problem, startTime));
70+
71+
pulseDataset.addSeries(series(problem.getPulse(), c.getScheme().getGrid().getTimeStep(),
72+
problem.getProperties().timeFactor(), startTime));
7073

7174
getPlot().setDataset(0, pulseDataset);
7275
}
7376

74-
private static XYSeries series(Problem problem, double startTime) {
75-
var pulse = problem.getPulse();
76-
77+
private static XYSeries series(Pulse pulse, double dx, double timeFactor, double startTime) {
7778
var series = new XYSeries(pulse.getPulseShape().toString());
78-
79-
double timeLimit = (double) pulse.getPulseWidth().getValue();
80-
final double timeFactor = problem.getProperties().timeFactor();
81-
82-
double dx = timeLimit / (NUM_PULSE_POINTS - 1);
83-
double x = startTime;
84-
85-
series.add(TO_MILLIS * (startTime - dx / 10.), 0.0);
86-
series.add(TO_MILLIS * (startTime + timeLimit + dx / 10.), 0.0);
87-
8879
var pulseShape = pulse.getPulseShape();
80+
81+
double timeLimit = pulseShape.getPulseWidth();
82+
double x = startTime/timeFactor;
83+
84+
series.add(TO_MILLIS * (startTime - dx * timeFactor / 10.), 0.0);
85+
series.add(TO_MILLIS * (startTime + timeFactor*(timeLimit + dx / 10.)), 0.0);
8986

90-
for (var i = 0; i < NUM_PULSE_POINTS; i++) {
91-
series.add(x * TO_MILLIS, pulseShape.evaluateAt((x - startTime) / timeFactor));
87+
for (int i = 0, numPoints = (int) (timeLimit/dx); i < numPoints; i++) {
88+
series.add(x * timeFactor * TO_MILLIS, pulseShape.evaluateAt(x - startTime/timeFactor));
9289
x += dx;
9390
}
9491

‎src/main/java/pulse/ui/components/panels/ProblemToolbar.java

Copy file name to clipboardExpand all lines: src/main/java/pulse/ui/components/panels/ProblemToolbar.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static void plot(ActionEvent e) {
8282
se.printStackTrace();
8383
}
8484
MainGraphFrame.getInstance().plot();
85-
TaskControlFrame.getInstance().getPulseFrame().plot(calc.getProblem().getPulse());
85+
TaskControlFrame.getInstance().getPulseFrame().plot(calc);
8686
}
8787

8888
}

‎src/main/java/pulse/ui/frames/TaskControlFrame.java

Copy file name to clipboardExpand all lines: src/main/java/pulse/ui/frames/TaskControlFrame.java
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import javax.swing.event.InternalFrameEvent;
2727

2828
import pulse.problem.statements.Pulse;
29+
import pulse.tasks.Calculation;
2930
import pulse.tasks.TaskManager;
3031
import pulse.ui.Version;
3132
import pulse.ui.components.PulseChart;
@@ -51,7 +52,7 @@ public class TaskControlFrame extends JFrame {
5152
private ResultFrame resultsFrame;
5253
private MainGraphFrame graphFrame;
5354
private LogFrame logFrame;
54-
private InternalGraphFrame<Pulse> pulseFrame;
55+
private InternalGraphFrame<Calculation> pulseFrame;
5556

5657
private PulseMainMenu mainMenu;
5758

@@ -201,7 +202,7 @@ private void initComponents() {
201202
searchOptionsFrame = new SearchOptionsFrame();
202203
searchOptionsFrame.setFrameIcon(loadIcon("optimiser.png", 20, Color.white));
203204

204-
pulseFrame = new InternalGraphFrame<Pulse>("Pulse Shape", new PulseChart("Time (ms)", "Laser Power (a. u.)"));
205+
pulseFrame = new InternalGraphFrame<Calculation>("Pulse Shape", new PulseChart("Time (ms)", "Laser Power (a. u.)"));
205206
pulseFrame.setFrameIcon(loadIcon("pulse.png", 20, Color.white));
206207
pulseFrame.setVisible(false);
207208

@@ -453,7 +454,7 @@ public Mode getMode() {
453454
return mode;
454455
}
455456

456-
public InternalGraphFrame<Pulse> getPulseFrame() {
457+
public InternalGraphFrame<Calculation> getPulseFrame() {
457458
return pulseFrame;
458459
}
459460

‎src/main/resources/NumericProperty.xml

Copy file name to clipboardExpand all lines: src/main/resources/NumericProperty.xml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@
351351
abbreviation="&lt;i&gt;d&lt;/i&gt;&lt;sub&gt;las&lt;/sub&gt; (mm)"
352352
visible="true"
353353
descriptor="Laser spot diameter, &lt;i&gt;d&lt;/i&gt;&lt;sub&gt;las&lt;/sub&gt; (mm)"
354-
dimensionfactor="1000.0" keyword="SPOT_DIAMETER" maximum="0.05"
354+
dimensionfactor="1000.0" keyword="SPOT_DIAMETER" maximum="0.2"
355355
minimum="1.0E-4" value="0.01" primitive-type="double" discreet="true">
356356
</NumericProperty>
357357
<NumericProperty

0 commit comments

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