From 1a922bea6404a1ca339f577c8c7b4e4f956f26ad Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Fri, 26 Apr 2024 08:25:55 +0200 Subject: [PATCH] added tests for saturation calculations (#991) --- .../bubblePointPressureFlashTest.java | 30 +++++++++++++++++ .../bubblePointTemperatureFlashTest.java | 29 +++++++++++++++++ .../dewPointPressureFlashTest.java | 32 +++++++++++++++++++ .../dewPointTemperatureFlashTest.java | 30 +++++++++++++++++ 4 files changed, 121 insertions(+) create mode 100644 src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointPressureFlashTest.java create mode 100644 src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointTemperatureFlashTest.java create mode 100644 src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/dewPointPressureFlashTest.java create mode 100644 src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/dewPointTemperatureFlashTest.java diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointPressureFlashTest.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointPressureFlashTest.java new file mode 100644 index 0000000000..ce294fb30f --- /dev/null +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointPressureFlashTest.java @@ -0,0 +1,30 @@ +package neqsim.thermodynamicOperations.flashOps.saturationOps; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; +import neqsim.thermo.system.SystemSrkEos; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +public class bubblePointPressureFlashTest { + @Test + void testRun() { + + SystemSrkEos fluid0_HC = new SystemSrkEos(); + fluid0_HC.addComponent("methane", 0.7); + fluid0_HC.addComponent("ethane", 0.1); + fluid0_HC.addComponent("propane", 0.1); + fluid0_HC.addComponent("n-butane", 0.1); + fluid0_HC.setMixingRule("classic"); + + fluid0_HC.setPressure(10.0, "bara"); + fluid0_HC.setTemperature(-50.0, "C"); + + ThermodynamicOperations ops = new ThermodynamicOperations(fluid0_HC); + try { + ops.bubblePointPressureFlash(false); + } catch (Exception e) { + e.printStackTrace(); + } + assertEquals(65.150271897839, fluid0_HC.getPressure(), 1e-2); + } +} diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointTemperatureFlashTest.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointTemperatureFlashTest.java new file mode 100644 index 0000000000..1e94ace143 --- /dev/null +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointTemperatureFlashTest.java @@ -0,0 +1,29 @@ +package neqsim.thermodynamicOperations.flashOps.saturationOps; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; +import neqsim.thermo.system.SystemSrkEos; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +public class bubblePointTemperatureFlashTest { + @Test + void testRun() { + SystemSrkEos fluid0_HC = new SystemSrkEos(); + fluid0_HC.addComponent("methane", 0.7); + fluid0_HC.addComponent("ethane", 0.1); + fluid0_HC.addComponent("propane", 0.1); + fluid0_HC.addComponent("n-butane", 0.1); + fluid0_HC.setMixingRule("classic"); + + fluid0_HC.setPressure(10.0, "bara"); + fluid0_HC.setTemperature(-150.0, "C"); + + ThermodynamicOperations ops = new ThermodynamicOperations(fluid0_HC); + try { + ops.bubblePointTemperatureFlash(); + } catch (Exception e) { + e.printStackTrace(); + } + assertEquals(-117.7205968083, fluid0_HC.getTemperature("C"), 1e-2); + } +} diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/dewPointPressureFlashTest.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/dewPointPressureFlashTest.java new file mode 100644 index 0000000000..d8e263882a --- /dev/null +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/dewPointPressureFlashTest.java @@ -0,0 +1,32 @@ +package neqsim.thermodynamicOperations.flashOps.saturationOps; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; +import neqsim.thermo.system.SystemSrkEos; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +public class dewPointPressureFlashTest { + @Test + void testRun() { + + + SystemSrkEos fluid0_HC = new SystemSrkEos(); + fluid0_HC.addComponent("methane", 0.7); + fluid0_HC.addComponent("ethane", 0.1); + fluid0_HC.addComponent("propane", 0.1); + fluid0_HC.addComponent("n-butane", 0.1); + fluid0_HC.setMixingRule("classic"); + + fluid0_HC.setPressure(10.0, "bara"); + fluid0_HC.setTemperature(0.0, "C"); + + ThermodynamicOperations ops = new ThermodynamicOperations(fluid0_HC); + try { + ops.dewPointPressureFlash(); + } catch (Exception e) { + e.printStackTrace(); + } + assertEquals(9.332383561, fluid0_HC.getPressure(), 1e-2); + + } +} diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/dewPointTemperatureFlashTest.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/dewPointTemperatureFlashTest.java new file mode 100644 index 0000000000..35d1b1f86f --- /dev/null +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/dewPointTemperatureFlashTest.java @@ -0,0 +1,30 @@ +package neqsim.thermodynamicOperations.flashOps.saturationOps; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; +import neqsim.thermo.system.SystemSrkEos; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +public class dewPointTemperatureFlashTest { + @Test + void testRun() { + SystemSrkEos fluid0_HC = new SystemSrkEos(); + fluid0_HC.addComponent("methane", 0.7); + fluid0_HC.addComponent("ethane", 0.1); + fluid0_HC.addComponent("propane", 0.1); + fluid0_HC.addComponent("n-butane", 0.1); + fluid0_HC.setMixingRule("classic"); + + fluid0_HC.setPressure(10.0, "bara"); + fluid0_HC.setTemperature(0.0, "C"); + + ThermodynamicOperations ops = new ThermodynamicOperations(fluid0_HC); + try { + ops.dewPointTemperatureFlash(); + } catch (Exception e) { + e.printStackTrace(); + } + assertEquals(1.7007677589821242, fluid0_HC.getTemperature("C"), 1e-2); + + } +}