Skip to content

Commit

Permalink
Fixes & Improvements
Browse files Browse the repository at this point in the history
- Fixed JUnit test not running
- Updated .pom
- Fixed JUnit test criterion for fluxes and derivatives. Now a linear
regression is built and its coefficient of determination is checked.
- Improved logging. Now important notes are showed in a pop-up window
prior to being written in the log. Exceptions that are written in the
log also trigger a ShowMessageDialog.
  • Loading branch information
Artem Lunev committed Jun 3, 2021
1 parent 043dd78 commit 8ba282e
Show file tree
Hide file tree
Showing 12 changed files with 170 additions and 115 deletions.
142 changes: 74 additions & 68 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,73 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>kotik-coder</groupId>
<artifactId>PULsE</artifactId>
<version>1.91FR</version>
<version>1.91FM</version>
<name>PULsE</name>
<description>Processing Unit for Laser flash Experiments</description>
<developers>
<developer>
<id>al</id>
<name>Artem Lunev</name>
<email>alounev@list.ru</email>
</developer>
</developers>
<licenses>
<license>
<name>The Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>

<dependencies>
<dependency>
<groupId>org.jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>com.weblookandfeel</groupId>
<artifactId>weblaf-ui</artifactId>
<version>1.2.13</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.6.1</version>
</dependency>
<dependency>
<groupId>ca.umontreal.iro.simul</groupId>
<artifactId>ssj</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>colt</groupId>
<artifactId>colt</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.ejml</groupId>
<artifactId>ejml-all</artifactId>
<version>0.39</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.7.0-M1</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.numericalmethod/suanshu-20120606 -->
</dependencies>

<build>
<sourceDirectory>src/main/java</sourceDirectory>
<testSourceDirectory>src/test</testSourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down Expand Up @@ -49,75 +111,19 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>
<configuration>
<additionalClasspathElements>
<additionalClasspathElement>src/test/java/</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>com.weblookandfeel</groupId>
<artifactId>weblaf-ui</artifactId>
<version>1.2.13</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.6.1</version>
</dependency>
<dependency>
<groupId>ca.umontreal.iro.simul</groupId>
<artifactId>ssj</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>colt</groupId>
<artifactId>colt</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.ejml</groupId>
<artifactId>ejml-all</artifactId>
<version>0.39</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>1.2.0</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.numericalmethod/suanshu-20120606 -->
</dependencies>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/pulse/input/ExperimentalData.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public double halfRiseTime() {
degraded.stream().map(point -> point.getY()).collect(Collectors.toList()));

if (index < 1) {
System.err.println(Messages.getString("ExperimentalData.HalfRiseError"));
System.out.println(Messages.getString("ExperimentalData.HalfRiseError"));
return max(getTimeSequence()) / FAIL_SAFE_FACTOR;
}

Expand Down
1 change: 0 additions & 1 deletion src/main/java/pulse/problem/statements/Problem.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package pulse.problem.statements;

import static pulse.input.listeners.CurveEventType.RESCALED;
import static pulse.math.transforms.StandardTransformations.LOG;
import static pulse.properties.NumericProperties.def;
import static pulse.properties.NumericProperties.derive;
import static pulse.properties.NumericPropertyKeyword.DIFFUSIVITY;
Expand Down
26 changes: 24 additions & 2 deletions src/main/java/pulse/ui/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class Launcher {

private Launcher() {
arrangeErrorOutput();
arrangeMessages();
}

/**
Expand Down Expand Up @@ -66,7 +67,7 @@ public static void main(String[] args) {
JOptionPane.showMessageDialog(null, "<html>A new version of this software is available: "
+ newVersion.toString() + "<br>Please visit the PULsE website for more details.</html>");
}

});
}

Expand Down Expand Up @@ -97,7 +98,17 @@ private void arrangeErrorOutput() {
try {
var dir = new File(decodedPath).getParent();
errorLog = new File(dir + File.separator + "ErrorLog_" + now() + ".log");
setErr(new PrintStream(errorLog));
setErr(new PrintStream(errorLog) {

@Override
public void println(String str) {
super.println(str);
JOptionPane.showMessageDialog(null, "An exception has occurred. "
+ "Please check the stored log!", "Exception", JOptionPane.ERROR_MESSAGE);
}

}
);
} catch (FileNotFoundException e) {
System.err.println("Unable to set up error stream");
e.printStackTrace();
Expand All @@ -106,6 +117,17 @@ private void arrangeErrorOutput() {
createShutdownHook();

}

private void arrangeMessages() {
System.setOut( new PrintStream(System.out) {

@Override
public void println(String str) {
JOptionPane.showMessageDialog(null, Messages.getString("TextWrap.0") + str + Messages.getString("TextWrap.0"));
}

});
}

private void createShutdownHook() {

Expand Down
11 changes: 5 additions & 6 deletions src/main/java/pulse/ui/frames/SearchOptionsFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,11 @@ public SearchOptionsFrame() {

public void update() {
var selected = getInstance();
if (selected != null) {
pathList.setSelectedIndex(pathSolvers.indexOf(selected));
pathTable.updateTable();
} else {
pathList.clearSelection();
}
if (selected == null)
TaskManager.getManagerInstance().selectFirstTask();

pathList.setSelectedIndex(pathSolvers.indexOf(selected));
pathTable.updateTable();
}

class PathSolversList extends JList<PathOptimiser> {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/Version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.91FR
1.91FM
4 changes: 3 additions & 1 deletion src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,6 @@ ImplicitScheme.4=<html><b>Fully Implicit Scheme</b><ul style='list-style-type:no
MixedScheme.2=Time interval too small:
MixedScheme.3=Problem not supported or unknown:
MixedScheme.4=<html><b>Symmetric Semi-Implicit Scheme</b><ul style='list-style-type:none'><li>Order of approximation <i>O</i>(<i>h</i><sup>2</sup> + <i>&tau</i><sup>2</sup>)</li><li>Unconditionally stable</li><li>Steps are computationally more expensive but their number is fewer compared to other schemes</li><li>Finite-difference representation of boundary conditions uses a Taylor expansion with three terms</li><li>Weight is set to 0.5</li></ul></html>
MixedScheme2.4=<html><b>Increased Accuracy Semi-implicit Scheme</b><ul style='list-style-type:none'><li>Order of approximation <i>O</i>(<i>h</i><sup>4</sup> + <i>&tau</i><sup>2</sup>)</li><li>Unconditionally stable</li><li>Steps are computationally more expensive but their number is fewer compared to other schemes</li><li>Finite-difference representation of boundary conditions uses a Taylor expansion with three terms</li><li>Auto-adjusts its weight and discrete representation of the flux derivative based on accuracy.</li></ul></html>
MixedScheme2.4=<html><b>Increased Accuracy Semi-implicit Scheme</b><ul style='list-style-type:none'><li>Order of approximation <i>O</i>(<i>h</i><sup>4</sup> + <i>&tau</i><sup>2</sup>)</li><li>Unconditionally stable</li><li>Steps are computationally more expensive but their number is fewer compared to other schemes</li><li>Finite-difference representation of boundary conditions uses a Taylor expansion with three terms</li><li>Auto-adjusts its weight and discrete representation of the flux derivative based on accuracy.</li></ul></html>
TextWrap.0=<html><body><p style='width: 300px;'>
TextWrap.1=</p></body></html>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package repository;
package test;

import static org.junit.jupiter.api.Assertions.assertTrue;
import static pulse.properties.NumericProperties.derive;
import static pulse.properties.NumericPropertyKeyword.OPTICAL_THICKNESS;
import static pulse.properties.NumericPropertyKeyword.QUADRATURE_POINTS;
import static repository.TestProfileLoader.loadTestProfileDense;
import static test.ProfileLoader.loadTestProfileDense;

import java.util.List;

Expand All @@ -19,10 +19,10 @@
import pulse.problem.schemes.rte.exact.NonscatteringRadiativeTransfer;
import pulse.problem.statements.model.ThermoOpticalProperties;

class AnalyticalNonscatteringTransferValidation {
class AnalyticalNonscatteringTestCase {

private static List<Double> testProfile;
private static NonscatteringTestCase testCase;
private static NonscatteringSetup testCase;

private NonscatteringRadiativeTransfer chand;
private RadiativeTransferSolver dom;
Expand All @@ -31,7 +31,7 @@ class AnalyticalNonscatteringTransferValidation {
@BeforeAll
static void setUpBeforeClass() throws Exception {
testProfile = loadTestProfileDense();
testCase = new NonscatteringTestCase(testProfile.size(), 10.0);
testCase = new NonscatteringSetup(testProfile.size(), 10.0);
}

@BeforeEach
Expand All @@ -47,23 +47,23 @@ void testFluxesLowThickness() {
quadrature.setQuadraturePoints(derive(QUADRATURE_POINTS, 2));
var properties = (ThermoOpticalProperties)testCase.getTestProblem().getProperties();
properties.setOpticalThickness(derive(OPTICAL_THICKNESS, 0.1));
assertTrue(testCase.testFluxesAndDerivatives(testProfile, chand, dom, 1e-2, 3e-1));
assertTrue(testCase.testFluxesAndDerivatives(testProfile, chand, dom, 1e-3, 1e-1));
}

@Test
void testFluxesMediumThickness() {
quadrature.setQuadraturePoints(derive(QUADRATURE_POINTS, 3));
var properties = (ThermoOpticalProperties)testCase.getTestProblem().getProperties();
properties.setOpticalThickness(derive(OPTICAL_THICKNESS, 1.5));
assertTrue(testCase.testFluxesAndDerivatives(testProfile, chand, dom, 1e-2, 1));
assertTrue(testCase.testFluxesAndDerivatives(testProfile, chand, dom, 1e-3, 1e-2));
}

@Test
void testFluxesHighThickness() {
quadrature.setQuadraturePoints(derive(QUADRATURE_POINTS, 6));
var properties = (ThermoOpticalProperties)testCase.getTestProblem().getProperties();
properties.setOpticalThickness(derive(OPTICAL_THICKNESS, 100.0));
assertTrue(testCase.testFluxesAndDerivatives(testProfile, chand, dom, 1e-1, Double.POSITIVE_INFINITY));
assertTrue(testCase.testFluxesAndDerivatives(testProfile, chand, dom, 1e-3, 1e-2));
}

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package repository;
package test;

import static org.junit.jupiter.api.Assertions.assertTrue;
import static pulse.properties.NumericProperties.derive;
import static pulse.properties.NumericPropertyKeyword.INTEGRATION_SEGMENTS;
import static pulse.properties.NumericPropertyKeyword.OPTICAL_THICKNESS;
import static repository.TestProfileLoader.loadTestProfileDense;
import static test.ProfileLoader.loadTestProfileDense;

import java.util.List;

Expand All @@ -19,18 +19,18 @@
import pulse.problem.schemes.rte.exact.NonscatteringRadiativeTransfer;
import pulse.problem.statements.model.ThermoOpticalProperties;

class DiscreteNonscatteringTransferValidation {
class DiscreteNonscatteringTestCase {

private static List<Double> testProfile;
private static NonscatteringTestCase testCase;
private static NonscatteringSetup testCase;

private NonscatteringRadiativeTransfer newton;
private RadiativeTransferSolver dom;

@BeforeAll
private static void setUpBeforeClass() {
testProfile = loadTestProfileDense();
testCase = new NonscatteringTestCase(testProfile.size(), 10.0);
testCase = new NonscatteringSetup(testProfile.size(), 10.0);
}

@BeforeEach
Expand All @@ -48,14 +48,14 @@ void setUp() throws Exception {
void testFluxesLowThickness() {
var properties = (ThermoOpticalProperties)testCase.getTestProblem().getProperties();
properties.setOpticalThickness(derive(OPTICAL_THICKNESS, 0.1));
assertTrue(testCase.testFluxesAndDerivatives(testProfile, newton, dom, 1e-2, 3e-1));
assertTrue(testCase.testFluxesAndDerivatives(testProfile, newton, dom, 1e-3, 1e-1));
}

@Test
void testFluxesMediumThickness() {
var properties = (ThermoOpticalProperties)testCase.getTestProblem().getProperties();
properties.setOpticalThickness(derive(OPTICAL_THICKNESS, 1.5));
assertTrue(testCase.testFluxesAndDerivatives(testProfile, newton, dom, 1e-2, 3e-1));
assertTrue(testCase.testFluxesAndDerivatives(testProfile, newton, dom, 1e-3, 1e-1));
}

}
Loading

0 comments on commit 8ba282e

Please sign in to comment.