Skip to content

Commit

Permalink
update units (#1008)
Browse files Browse the repository at this point in the history
  • Loading branch information
EvenSol committed May 9, 2024
1 parent 4c18143 commit 2f43e3f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/main/java/neqsim/util/unit/Units.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ public UnitDescription(String symbol, String symbolName) {
private static HashMap<String, UnitDescription> siUnits = new HashMap<>();
private static HashMap<String, UnitDescription> fieldUnits = new HashMap<>();

private static String[] pressureUnits = new String[] { "Pa", "bara", "barg", "psi", "psig", "psia" };
private static String[] temperatureUnits = new String[] { "K", "C", "F", "R" };
private static String[] molarVolumeUnits = new String[] { "mol/m3", "litre/m3", "ft3/lbmole" };
private static String[] pressureUnits =
new String[] {"Pa", "bara", "barg", "psi", "psig", "psia"};
private static String[] temperatureUnits = new String[] {"K", "C", "F", "R"};
private static String[] molarVolumeUnits = new String[] {"mol/m3", "litre/m3", "ft3/lbmole"};

public Units() {
if (activeUnits.size() == 0) {
Expand All @@ -48,15 +49,16 @@ public Units() {
activeUnits.put("JT coefficient", new UnitDescription("C/bar", "Celsius per bar"));
activeUnits.put("speed of sound", new UnitDescription("m/sec", "meter per second"));
activeUnits.put("Heat Capacity (Cv)",
new UnitDescription("kJ/kg*K", "kilo joule per kg and Kelvin"));
new UnitDescription("kJ/kgK", "kilo joule per kg and Kelvin"));
activeUnits.put("Heat Capacity (Cp)",
new UnitDescription("kJ/kg*K", "kilo joule per kg and Kelvin"));
new UnitDescription("kJ/kgK", "kilo joule per kg and Kelvin"));
activeUnits.put("Molar Mass", new UnitDescription("kg/mol", "kilo gram per kilo mole"));
activeUnits.put("molar volume", new UnitDescription("m3/mol", "cubic metre per mole"));
activeUnits.put("mass flow", new UnitDescription("kg/hr", "kg per hour"));
activeUnits.put("molar flow", new UnitDescription("mole/hr", "mole per hour"));
activeUnits.put("volume flow", new UnitDescription("m3/hr", "cubic metre per hour"));
activeUnits.put("standard volume flow", new UnitDescription("Sm3/hr", "standard cubic metre per hour"));
activeUnits.put("standard volume flow",
new UnitDescription("Sm3/hr", "standard cubic metre per hour"));

siUnits.putAll(activeUnits); // Makes a copy of activeUnits
siUnits.put("temperature", new UnitDescription("K", "Kelvin"));
Expand Down
17 changes: 17 additions & 0 deletions src/test/java/neqsim/thermo/system/SystemThermoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,23 @@ public static void setUp() {
testSystem.initProperties();
}

/**
* <p>
* setUp.
* </p>
*/
@Test
public void testCp() {
testSystem = new neqsim.thermo.system.SystemPrEos(273.15 + 40.0, 1.0);
testSystem.addComponent("methane", 10.01);
testSystem.addComponent("nC20", 10.68);
testSystem.setMixingRule("classic");
ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem);
testOps.TPflash();
testSystem.initProperties();
assertEquals(2.274301427480528, testSystem.getPhase(0).getCp("kJ/kgK"), 1e-6);
}

/**
* <p>
* test setPressure
Expand Down

0 comments on commit 2f43e3f

Please sign in to comment.