-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for ParabolicEquation (need to add analytic solution)
Remove Main class
- Loading branch information
1 parent
5278898
commit 79d5663
Showing
4 changed files
with
48 additions
and
18 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/test/java/by/andd3dfx/math/pde/ParabolicEquationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package by.andd3dfx.math.pde; | ||
|
||
import by.andd3dfx.math.Interval; | ||
import by.andd3dfx.util.FileUtil; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class ParabolicEquationTest { | ||
|
||
private final double C_LEFT = 1.0; | ||
private final double THICKNESS = 1e-3; // 1mm | ||
private final double TIME = 1; // 1sec | ||
private final double DIFFUSION_COEFFICIENT = 1e-4; | ||
|
||
@Test | ||
void solve() { | ||
var h = THICKNESS / 1000.0; | ||
var tau = TIME / 1000.0; | ||
|
||
var diffusionEquation = new ParabolicEquation(0, THICKNESS, TIME) { | ||
@Override | ||
protected double gK(double x, double t, double U) { | ||
return DIFFUSION_COEFFICIENT; | ||
} | ||
|
||
@Override | ||
protected double gLU(double t) { | ||
return C_LEFT; | ||
} | ||
}; | ||
|
||
diffusionEquation.solve(h, tau); | ||
|
||
diffusionEquation.sUt("./build/res-numeric.txt", TIME); | ||
FileUtil.saveFunc( | ||
new Interval(0, THICKNESS, h), | ||
(x) -> analyticSolution(x, TIME), | ||
"./build/res-analytic.txt" | ||
); | ||
} | ||
|
||
private double analyticSolution(double x, double t) { | ||
// TODO add analytic solution | ||
return 0; | ||
} | ||
} |