Skip to content

Commit

Permalink
Model improvements
Browse files Browse the repository at this point in the history
- Convective heat losses now introduced in diathermic and participating
medium models
- Emissivity can now be output in the result format dialog
  • Loading branch information
kotik-coder committed Jun 8, 2022
1 parent 1ce1f8e commit 6548fbb
Show file tree
Hide file tree
Showing 20 changed files with 169 additions and 80 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>kotik-coder</groupId>
<artifactId>PULsE</artifactId>
<version>1.94F</version>
<version>1.95</version>
<name>PULsE</name>
<description>Processing Unit for Laser flash Experiments</description>
<developers>
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/pulse/input/InterpolationDataset.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import static pulse.properties.NumericPropertyKeyword.SPECIFIC_HEAT;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;

Expand All @@ -14,6 +14,7 @@

import pulse.input.listeners.ExternalDatasetListener;
import pulse.properties.NumericPropertyKeyword;
import static pulse.properties.NumericPropertyKeyword.EMISSIVITY;
import pulse.util.ImmutableDataEntry;

/**
Expand All @@ -29,9 +30,10 @@
public class InterpolationDataset {

private UnivariateFunction interpolation;
private List<ImmutableDataEntry<Double, Double>> dataset;
private static Map<StandartType, InterpolationDataset> standartDatasets = new HashMap<StandartType, InterpolationDataset>();
private static List<ExternalDatasetListener> listeners = new ArrayList<>();
private final List<ImmutableDataEntry<Double, Double>> dataset;
private static final Map<StandartType, InterpolationDataset> standartDatasets
= new EnumMap<StandartType, InterpolationDataset>(StandartType.class);
private static final List<ExternalDatasetListener> listeners = new ArrayList<>();

/**
* Creates an empty {@code InterpolationDataset}.
Expand Down Expand Up @@ -121,6 +123,7 @@ public static List<NumericPropertyKeyword> derivableProperties() {
}
if (list.contains(SPECIFIC_HEAT) && list.contains(DENSITY)) {
list.add(CONDUCTIVITY);
list.add(EMISSIVITY);
}
return list;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public void prepare(Problem problem) throws SolverException {
hx = grid.getXStep();

var p = (ThermoOpticalProperties) problem.getProperties();
double Bi = (double) p.getHeatLoss().getValue();
//combined Biot
double Bi = (double) p.getHeatLoss().getValue() + (double) p.getConvectiveLosses().getValue();

a = 1. / (1. + Bi * hx);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

import pulse.problem.schemes.DifferenceScheme;
import pulse.problem.schemes.FixedPointIterations;
import pulse.problem.statements.ParticipatingMedium;
import pulse.problem.statements.Problem;
import static pulse.properties.NumericProperties.def;
import static pulse.properties.NumericProperties.derive;
import pulse.properties.NumericProperty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public void prepare(Problem problem) throws SolverException {
final double tau = grid.getTimeStep();

var p = (ThermoOpticalProperties) problem.getProperties();
final double Bi1 = (double) p.getHeatLoss().getValue();
//combined Biot
final double Bi1 = (double) p.getHeatLoss().getValue() + (double) p.getConvectiveLosses().getValue();
final double Np = (double) p.getPlanckNumber().getValue();
final double tau0 = (double) p.getOpticalThickness().getValue();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

import pulse.problem.schemes.DifferenceScheme;
import pulse.problem.schemes.FixedPointIterations;
import pulse.problem.statements.ParticipatingMedium;
import pulse.problem.statements.Problem;
import static pulse.properties.NumericProperties.def;
import static pulse.properties.NumericProperties.derive;
import pulse.properties.NumericProperty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ public void prepare(Problem problem) throws SolverException {
/* Constants */
var properties = (DiathermicProperties) problem.getProperties();

final double Bi1 = (double) properties.getHeatLoss().getValue();
final double BiR = (double) properties.getHeatLoss().getValue();
final double BiC = (double) properties.getConvectiveLosses().getValue();
final double eta = (double) properties.getDiathermicCoefficient().getValue();

z0 = 1.0 + HX2_2TAU + hx * Bi1 * (1.0 + eta);
zN_1 = -hx * eta * Bi1;
z0 = 1.0 + HX2_2TAU + hx * BiR * (1.0 + eta) + hx * BiC;
zN_1 = -hx * eta * BiR;

/* End of constants */
var tridiagonal = new BlockMatrixAlgorithm(grid);
Expand Down Expand Up @@ -106,4 +107,4 @@ public Class<? extends Problem>[] domain() {
return new Class[]{DiathermicMedium.class};
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ public void prepare(Problem problem) throws SolverException {
hx = grid.getXStep();
tau = grid.getTimeStep();

Bi1 = (double) problem.getProperties().getHeatLoss().getValue();
var properties = (ThermoOpticalProperties)problem.getProperties();
//combined biot
Bi1 = (double) properties.getHeatLoss().getValue() +
(double) properties.getConvectiveLosses().getValue();

zeta = (double) ( (ClassicalProblem)problem ).getGeometricFactor().getValue();

Expand Down
38 changes: 27 additions & 11 deletions src/main/java/pulse/problem/statements/DiathermicMedium.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import pulse.problem.statements.model.DiathermicProperties;
import pulse.problem.statements.model.ThermalProperties;
import pulse.properties.Flag;
import static pulse.properties.NumericPropertyKeyword.HEAT_LOSS_CONVECTIVE;
import pulse.ui.Messages;

/**
Expand Down Expand Up @@ -60,17 +61,31 @@ public void optimisationVector(ParameterVector output, List<Flag> flags) {
for (int i = 0, size = output.dimension(); i < size; i++) {

var key = output.getIndex(i);
Segment bounds = null;
double value = 0;

if (key == DIATHERMIC_COEFFICIENT) {

var bounds = Segment.boundsFrom(DIATHERMIC_COEFFICIENT);
final double etta = (double) properties.getDiathermicCoefficient().getValue();

output.setTransform(i, new StickTransform(bounds));
output.set(i, etta);
output.setParameterBounds(i, bounds);

switch (key) {
case DIATHERMIC_COEFFICIENT:
bounds = Segment.boundsFrom(DIATHERMIC_COEFFICIENT);
value = (double) properties.getDiathermicCoefficient().getValue();
break;
case HEAT_LOSS_CONVECTIVE:
bounds = Segment.boundsFrom(HEAT_LOSS_CONVECTIVE);
value = (double) properties.getConvectiveLosses().getValue();
break;
case HEAT_LOSS:
if(properties.areThermalPropertiesLoaded()) {
value = (double) properties.getHeatLoss().getValue();
bounds = new Segment(0.0, properties.maxRadiationBiot() );
break;
}
default:
continue;
}

output.setTransform(i, new StickTransform(bounds));
output.set(i, value);
output.setParameterBounds(i, bounds);

}

Expand All @@ -90,9 +105,10 @@ public void assign(ParameterVector params) throws SolverException {
case DIATHERMIC_COEFFICIENT:
properties.setDiathermicCoefficient(derive(DIATHERMIC_COEFFICIENT, params.inverseTransform(i)));
break;
case HEAT_LOSS_CONVECTIVE:
properties.setConvectiveLosses(derive(HEAT_LOSS_CONVECTIVE, params.inverseTransform(i)));
break;
default:
continue;

}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@
import static pulse.properties.NumericProperty.requireType;
import pulse.properties.NumericPropertyKeyword;
import static pulse.properties.NumericPropertyKeyword.DIATHERMIC_COEFFICIENT;
import static pulse.properties.NumericPropertyKeyword.HEAT_LOSS_CONVECTIVE;

public class DiathermicProperties extends ThermalProperties {

private double diathermicCoefficient;
private double convectiveLosses;

public DiathermicProperties() {
super();
this.diathermicCoefficient = (double) def(DIATHERMIC_COEFFICIENT).getValue();
this.convectiveLosses = (double) def(HEAT_LOSS_CONVECTIVE).getValue();
}

public DiathermicProperties(ThermalProperties p) {
Expand All @@ -23,8 +26,10 @@ public DiathermicProperties(ThermalProperties p) {
? ((DiathermicProperties) p).getDiathermicCoefficient()
: def(DIATHERMIC_COEFFICIENT);
this.diathermicCoefficient = (double) property.getValue();
this.convectiveLosses = (double) property.getValue();
}

@Override
public ThermalProperties copy() {
return new ThermalProperties(this);
}
Expand All @@ -37,21 +42,38 @@ public void setDiathermicCoefficient(NumericProperty diathermicCoefficient) {
requireType(diathermicCoefficient, DIATHERMIC_COEFFICIENT);
this.diathermicCoefficient = (double) diathermicCoefficient.getValue();
}

public NumericProperty getConvectiveLosses() {
return derive(HEAT_LOSS_CONVECTIVE, convectiveLosses);
}

public void setConvectiveLosses(NumericProperty convectiveLosses) {
requireType(convectiveLosses, HEAT_LOSS_CONVECTIVE);
this.convectiveLosses = (double) convectiveLosses.getValue();
}

@Override
public void set(NumericPropertyKeyword type, NumericProperty property) {
if (type == DIATHERMIC_COEFFICIENT) {
diathermicCoefficient = ((Number) property.getValue()).doubleValue();
} else {
super.set(type, property);
double value = ((Number) property.getValue()).doubleValue();
switch (type) {
case DIATHERMIC_COEFFICIENT:
diathermicCoefficient = value;
break;
case HEAT_LOSS_CONVECTIVE:
convectiveLosses = value;
break;
default:
super.set(type, property);
break;
}
}

@Override
public Set<NumericPropertyKeyword> listedKeywords() {
var set = super.listedKeywords();
set.add(DIATHERMIC_COEFFICIENT);
set.add(HEAT_LOSS_CONVECTIVE);
return set;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public ThermalProperties copy() {
public void useTheoreticalEstimates(ExperimentalData c) {
super.useTheoreticalEstimates(c);
if (areThermalPropertiesLoaded()) {
Bi3 = biot();
Bi3 = radiationBiot();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ public void set(NumericPropertyKeyword type, NumericProperty value) {
public void setHeatLoss(NumericProperty Bi) {
requireType(Bi, HEAT_LOSS);
this.Bi = (double) Bi.getValue();
if(areThermalPropertiesLoaded()) {
calculateEmissivity();
}
firePropertyChanged(this, Bi);
}

Expand Down Expand Up @@ -272,6 +275,7 @@ public Set<NumericPropertyKeyword> listedKeywords() {
set.add(HEAT_LOSS);
set.add(DENSITY);
set.add(SPECIFIC_HEAT);
set.add(EMISSIVITY);
return set;
}

Expand All @@ -285,16 +289,33 @@ public NumericProperty getThermalConductivity() {

public void calculateEmissivity() {
double newEmissivity = Bi * thermalConductivity() / (4. * Math.pow(T, 3) * l * STEFAN_BOTLZMAN);
var transform = new StickTransform(new Segment(0.01, 1.0));
var transform = new StickTransform(Segment.boundsFrom(EMISSIVITY));
setEmissivity(derive(EMISSIVITY,
transform.transform(newEmissivity))
);
}

public double biot() {
/**
* Calculates the radiative Biot number.
* @return the radiative Biot number.
*/

public double radiationBiot() {
double lambda = thermalConductivity();
return 4.0 * emissivity * STEFAN_BOTLZMAN * Math.pow(T, 3) * l / lambda;
}

/**
* Calculates the maximum Biot number at these conditions, which
* corresponds to an emissivity of unity. If emissivity is non-positive,
* returns the maximum Biot number defined in the XML file.
* @return the maximum Biot number
*/

public double maxRadiationBiot() {
double absMax = Segment.boundsFrom(HEAT_LOSS).getMaximum();
return emissivity > 0 ? radiationBiot() / emissivity : absMax;
}

/**
* Performs simple calculation of the <math><i>l<sup>2</sup>/a</i></math>
Expand All @@ -320,7 +341,7 @@ public void useTheoreticalEstimates(ExperimentalData c) {
final double t0 = c.getHalfTime();
this.a = PARKERS_COEFFICIENT * l * l / t0;
if (areThermalPropertiesLoaded()) {
Bi = biot();
Bi = radiationBiot();
}
}

Expand Down
Loading

0 comments on commit 6548fbb

Please sign in to comment.