Skip to content

Commit

Permalink
added tests (#1163)
Browse files Browse the repository at this point in the history
  • Loading branch information
EvenSol authored Nov 3, 2024
1 parent 76c9d73 commit 9e7143a
Show file tree
Hide file tree
Showing 2 changed files with 205 additions and 0 deletions.
106 changes: 106 additions & 0 deletions src/test/java/neqsim/thermo/util/gerg/DETAILTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package neqsim.thermo.util.gerg;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.netlib.util.StringW;
import org.netlib.util.doubleW;
import org.netlib.util.intW;

public class DETAILTest {
private DETAIL detail;

@BeforeEach
public void setUp() {
detail = new DETAIL();
detail.SetupDetail();
}

@Test
public void testSq() {
double result = detail.sq(3.0);
assertEquals(9.0, result, 1e-6);
}

@Test
public void testMolarMassDetail() {
double[] x = new double[22];
x[1] = 0.94;
x[3] = 0.05;
x[20] = 0.01;
doubleW Mm = new doubleW(0.0);
detail.MolarMassDetail(x, Mm);
assertEquals(17.320946, Mm.val, 1e-3);
}

@Test
public void testPressureDetail() {
double T = 300.0;
double D = 10.0;
double[] x = new double[22];
x[1] = 0.94;
x[3] = 0.05;
x[20] = 0.01;
doubleW P = new doubleW(0.0);
doubleW Z = new doubleW(0.0);
detail.PressureDetail(T, D, x, P, Z);
assertTrue(P.val > 0);
assertTrue(Z.val > 0);
}

@Test
public void testDensityDetail() {
double T = 300.0;
double P = 1000.0;
double[] x = new double[22];
x[1] = 0.94;
x[3] = 0.05;
x[20] = 0.01;
doubleW D = new doubleW(-1.0);
intW ierr = new intW(0);
StringW herr = new StringW("");
detail.DensityDetail(T, P, x, D, ierr, herr);
assertEquals(0, ierr.val);
assertTrue(D.val > 0);
}

@Test
public void testPropertiesDetail() {
double T = 300.0;
double D = 10.0;
double[] x = new double[22];
x[1] = 0.94;
x[3] = 0.05;
x[20] = 0.01;
doubleW P = new doubleW(0.0);
doubleW Z = new doubleW(0.0);
doubleW dPdD = new doubleW(0.0);
doubleW d2PdD2 = new doubleW(0.0);
doubleW d2PdTD = new doubleW(0.0);
doubleW dPdT = new doubleW(0.0);
doubleW U = new doubleW(0.0);
doubleW H = new doubleW(0.0);
doubleW S = new doubleW(0.0);
doubleW Cv = new doubleW(0.0);
doubleW Cp = new doubleW(0.0);
doubleW W = new doubleW(0.0);
doubleW G = new doubleW(0.0);
doubleW JT = new doubleW(0.0);
doubleW Kappa = new doubleW(0.0);
detail.PropertiesDetail(T, D, x, P, Z, dPdD, d2PdD2, d2PdTD, dPdT, U, H, S, Cv, Cp, W, G, JT,
Kappa);
assertTrue(P.val > 0);
assertTrue(Z.val > 0);
assertFalse(U.val > 0);
assertFalse(H.val > 0);
assertTrue(S.val < 0);
assertTrue(Cv.val > 0);
assertTrue(Cp.val > 0);
assertTrue(W.val > 0);
assertTrue(G.val > 0);
assertTrue(JT.val != 0);
assertTrue(Kappa.val > 0);
}
}
99 changes: 99 additions & 0 deletions src/test/java/neqsim/thermo/util/gerg/GERG2008Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package neqsim.thermo.util.gerg;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.netlib.util.StringW;
import org.netlib.util.doubleW;
import org.netlib.util.intW;



public class GERG2008Test {
private GERG2008 gerg;

@BeforeEach
public void setUp() {
gerg = new GERG2008();
gerg.SetupGERG();
}

@Test
public void testMolarMassGERG() {
double[] x = new double[22];
x[1] = 1.0; // Pure methane
doubleW Mm = new doubleW(0.0);
gerg.MolarMassGERG(x, Mm);
assertEquals(16.04246, Mm.val, 1e-5);
}

@Test
public void testPressureGERG() {
double T = 300.0;
double D = 10.0;
double[] x = new double[22];
x[1] = 1.0; // Pure methane
doubleW P = new doubleW(0.0);
doubleW Z = new doubleW(0.0);
gerg.PressureGERG(T, D, x, P, Z);
assertTrue(P.val > 0);
assertTrue(Z.val > 0);
}

@Test
public void testDensityGERG() {
int iFlag = 0;
double T = 300.0;
double P = 1000.0;
double[] x = new double[22];
x[1] = 1.0; // Pure methane
doubleW D = new doubleW(0.0);
intW ierr = new intW(0);
StringW herr = new StringW("");
gerg.DensityGERG(iFlag, T, P, x, D, ierr, herr);
assertEquals(0, ierr.val);
assertTrue(D.val > 0);
assertEquals(0.4077469060672, D.val, 1e-5);
}

@Test
public void testPropertiesGERG() {
double T = 300.0;
double D = 10.0;
double[] x = new double[22];
x[1] = 1.0; // Pure methane
doubleW P = new doubleW(0.0);
doubleW Z = new doubleW(0.0);
doubleW dPdD = new doubleW(0.0);
doubleW d2PdD2 = new doubleW(0.0);
doubleW d2PdTD = new doubleW(0.0);
doubleW dPdT = new doubleW(0.0);
doubleW U = new doubleW(0.0);
doubleW H = new doubleW(0.0);
doubleW S = new doubleW(0.0);
doubleW Cv = new doubleW(0.0);
doubleW Cp = new doubleW(0.0);
doubleW W = new doubleW(0.0);
doubleW G = new doubleW(0.0);
doubleW JT = new doubleW(0.0);
doubleW Kappa = new doubleW(0.0);
doubleW A = new doubleW(0.0);
gerg.PropertiesGERG(T, D, x, P, Z, dPdD, d2PdD2, d2PdTD, dPdT, U, H, S, Cv, Cp, W, G, JT, Kappa,
A);
assertTrue(P.val > 0);
assertTrue(Z.val > 0);
assertTrue(U.val != 0);
assertTrue(H.val != 0);
assertTrue(S.val != 0);
assertTrue(Cv.val != 0);
assertTrue(Cp.val != 0);
assertTrue(W.val != 0);
assertTrue(G.val != 0);
assertTrue(JT.val != 0);
assertTrue(Kappa.val != 0);
assertTrue(A.val != 0);
assertEquals(0.83232372466, Z.val, 1e-5);

}
}

0 comments on commit 9e7143a

Please sign in to comment.