@@ -53,6 +53,81 @@ void testFlash() {
53
53
}
54
54
}
55
55
56
+ @ Test
57
+ void testFluidDefined () {
58
+ double [] fractions = new double [] {98.0 , 2.0 };
59
+ List <Double > Sp1 =
60
+ Arrays .asList (new Double [] {22.1 , 23.2 , 24.23 , 25.98 , 25.23 , 26.1 , 27.3 , 28.7 , 23.5 , 22.7 });
61
+ List <Double > Sp2 = Arrays .asList (
62
+ new Double [] {288.1 , 290.1 , 295.1 , 301.2 , 299.3 , 310.2 , 315.3 , 310.0 , 305.2 , 312.7 });
63
+ List <String > components = Arrays .asList (new String [] {"O2" , "N2" });
64
+ List <List <Double >> onlineFractions = new ArrayList <List <Double >>();
65
+
66
+ for (double d : fractions ) {
67
+ ArrayList <Double > l = new ArrayList <Double >();
68
+ for (int i = 0 ; i < Sp1 .size (); i ++) {
69
+ l .add (d );
70
+ }
71
+ onlineFractions .add (l );
72
+ }
73
+
74
+ SystemInterface fluid_static = new SystemSrkEos (273.15 + 45.0 , 22.0 );
75
+ fluid_static .addComponent ("N2" , fractions [0 ]);
76
+ fluid_static .addComponent ("O2" , fractions [1 ]);
77
+ fluid_static .setMixingRule (2 );
78
+ fluid_static .useVolumeCorrection (true );
79
+ fluid_static .setMultiPhaseCheck (true );
80
+ // fluid_static.init(0);
81
+
82
+ ThermodynamicOperations fluidOps_static = new ThermodynamicOperations (fluid_static );
83
+ CalculationResult res_static = fluidOps_static .propertyFlash (Sp1 , Sp2 , 1 , null , null );
84
+
85
+ for (String err : res_static .calculationError ) {
86
+ Assertions .assertEquals (err ,
87
+ "Sum of fractions must be approximately to 1 or 100, currently (0.0). Have you called init(0)?" );
88
+ }
89
+ // fluid_static.setTotalNumberOfMoles(1);
90
+ fluid_static .init (0 );
91
+ res_static = fluidOps_static .propertyFlash (Sp1 , Sp2 , 1 , null , null );
92
+ for (String err : res_static .calculationError ) {
93
+ Assertions .assertEquals (err , null );
94
+ }
95
+
96
+ SystemInterface fluid = new SystemSrkEos (273.15 + 45.0 , 22.0 );
97
+ fluid .addComponent ("nitrogen" , 0.79 );
98
+ fluid .addComponent ("oxygen" , 0.21 );
99
+ fluid .setMixingRule (2 );
100
+ fluid .useVolumeCorrection (true );
101
+ fluid .setMultiPhaseCheck (true );
102
+
103
+ ThermodynamicOperations fluidOps = new ThermodynamicOperations (fluid );
104
+ CalculationResult res = fluidOps .propertyFlash (Sp1 , Sp2 , 1 , components , onlineFractions );
105
+ Assertions .assertEquals (Sp1 .size (), res .calculationError .length );
106
+ for (String err : res .calculationError ) {
107
+ Assertions .assertNull (err );
108
+ }
109
+
110
+ fluid = new SystemSrkEos (273.15 + 45.0 , 22.0 );
111
+ fluid .addComponent ("N2" , 0.79 );
112
+ fluid .addComponent ("O2" , 0.21 );
113
+ fluid .setMixingRule (2 );
114
+ fluid .useVolumeCorrection (true );
115
+ fluid .setMultiPhaseCheck (true );
116
+
117
+
118
+ fluidOps = new ThermodynamicOperations (fluid );
119
+ CalculationResult res2 = fluidOps .propertyFlash (Sp1 , Sp2 , 1 , components , onlineFractions );
120
+ Assertions .assertEquals (Sp1 .size (), res2 .calculationError .length );
121
+ for (String err : res2 .calculationError ) {
122
+ Assertions .assertNull (err );
123
+ }
124
+
125
+ Assertions .assertEquals (res , res2 );
126
+ // todo: why does below not work?
127
+
128
+ // Assertions.assertArrayEquals(res_static.fluidProperties[0], res.fluidProperties[0]);
129
+ }
130
+
56
131
@ Test
57
132
void testNeqSimPython () {
58
133
SystemInterface thermoSystem = new neqsim .thermo .system .SystemSrkEos (280.0 , 10.0 );
0 commit comments