Skip to content

Commit

Permalink
test: add LNGship unit tests (#878)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgenengelsen authored Dec 11, 2023
1 parent 6ad9d91 commit b3adc86
Showing 1 changed file with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package neqsim.fluidMechanics.flowSystem.twoPhaseFlowSystem.shipSystem;

import neqsim.thermo.system.SystemInterface;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

class LNGshipTest {

LNGship testShip;
SystemInterface testSystem;
@BeforeEach
void setUp() {
testSystem = new neqsim.thermo.system.SystemSrkEos(100, 1.0);
testSystem.addComponent("methane", 0.9);
testSystem.addComponent("nitrogen", 0.1);
testSystem.init(0);

testShip = new LNGship(testSystem, 1_000_000, 0.01);
}

@Test
void createSystem() {
assertEquals(0.7, testShip.getLiquidDensity());
assertEquals(0.0, testShip.dailyBoilOffVolume);
assertEquals(0.0, testShip.initialNumberOffMoles);
testShip.createSystem();
assertEquals(474.3293447569919, testShip.getLiquidDensity());
assertEquals(10_000.0, testShip.dailyBoilOffVolume);
assertEquals(2.7513223265419292E10, testShip.initialNumberOffMoles);

}

@Test
public void testSolveSteadyState() {
assertEquals(-173.15, testShip.getThermoSystem().getTemperature("C"), 1e-2);
testShip.createSystem();
testShip.solveSteadyState(1, null);
assertEquals(-176.43, testShip.getThermoSystem().getTemperature("C"), 1e-2);
assertEquals(testSystem.getPhase("oil").getComponent("nitrogen").getx(), testShip.getThermoSystem().getPhase("oil").getComponent("nitrogen").getx(), 1e-4);
assertEquals(testSystem.getPhase("oil").getComponent("methane").getx(), testShip.getThermoSystem().getPhase("oil").getComponent("methane").getx(), 1e-4);
}

@Test
void solveTransient() {
assertNull(testShip.volume);
assertEquals(0.0, testShip.endVolume);
assertEquals(1_000_000, testShip.totalTankVolume); // Initial cargo volume

testShip.createSystem();
testShip.solveSteadyState(0, null);
testShip.solveTransient(0, null);


assertEquals(testShip.numberOffTimeSteps, testShip.tankTemperature.length); // Check that the results have correct length
assertEquals(600_000.0, testShip.endVolume);
}
}

0 comments on commit b3adc86

Please sign in to comment.