Skip to content

Commit 262e9a5

Browse files
committed
update
1 parent 85d7fa0 commit 262e9a5

File tree

5 files changed

+21
-23
lines changed

5 files changed

+21
-23
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "neqsim"
3-
version = "3.1.5"
3+
version = "3.2.0"
44
homepage = "https://github.com/Equinor/neqsim-python"
55
description = "NeqSim is a tool for thermodynamic and process calculations"
66
authors = ["Even Solbraa <[email protected]>"]
38.4 MB
Binary file not shown.

src/neqsim/process/unitop.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def equals(self, obj):
4242
@JOverride # Implement the missing 'hashCode' method
4343
def hashCode(self):
4444
# Implement your hash code logic here.
45-
# A simple example is to return the hash of the object's name:
46-
return hash(self.name)
45+
# Ensure the hash fits within Java int range (-2^31 to 2^31-1)
46+
return hash(self.name) & 0x7FFFFFFF
4747

4848
@JOverride # Implement the missing 'setController' method
4949
def setController(self, controller):
@@ -176,7 +176,7 @@ def setRegulatorOutSignal(self):
176176
# Add the logic to calculate or retrieve the pressure.
177177

178178
@JOverride # Implement the missing 'run' method
179-
def run(self, id):
179+
def run(self, id=None):
180180
pass
181181

182182
@JOverride # Implement the missing 'setTime' method
@@ -200,19 +200,18 @@ def solved(self):
200200
return True # Replace 0.0 with the actual pressure value or calculatio
201201
# Add the logic to calculate or retrieve the pressure.
202202

203-
@JOverride # Implement the missing 'getExergyChange' method
203+
@JOverride # Implement the missing 'getCalculationIdentifier' method
204204
def getCalculationIdentifier(self):
205-
# Add the logic to calculate or retrieve the pressure.
206-
# This will depend on how pressure is handled in your 'unitop' class.
207-
return 0.0 # Replace 0.0 with the actual pressure value or calculatio
208-
# Add the logic to calculate or retrieve the pressure.
205+
# Return the stored calculation identifier UUID
206+
if not hasattr(self, '_calculationIdentifier') or self._calculationIdentifier is None:
207+
import java.util
208+
self._calculationIdentifier = java.util.UUID.randomUUID()
209+
return self._calculationIdentifier
209210

210-
@JOverride # Implement the missing 'getExergyChange' method
211+
@JOverride # Implement the missing 'setCalculationIdentifier' method
211212
def setCalculationIdentifier(self, idf):
212-
# Add the logic to calculate or retrieve the pressure.
213-
# This will depend on how pressure is handled in your 'unitop' class.
214-
pass # Replace 0.0 with the actual pressure value or calculatio
215-
# Add the logic to calculate or retrieve the pressure.
213+
# Store the calculation identifier UUID
214+
self._calculationIdentifier = idf
216215

217216
@JOverride # Implement the missing 'getExergyChange' method
218217
def getCalculateSteadyState(self):

tests/process/test_unitop.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ def getOutputStream(self):
2626
return self.outputstream
2727

2828
@JOverride
29-
def run(self, id):
30-
print("here2")
29+
def run(self, id=None):
30+
"""Doubles the input stream pressure and updates the output stream."""
31+
# Get the current input stream's fluid
3132
fluid2 = self.inputstream.getFluid().clone()
32-
fluid2.setPressure(fluid2.getPressure() * 2.0)
33-
self.outputstream.setFluid(fluid2)
34-
self.outputstream.run()
33+
fluid2.setPressure(self.inputstream.getPressure() * 2.0)
34+
self.getOutputStream().setFluid(fluid2)
35+
self.getOutputStream().run()
3536

3637

3738
def test_addPythonUnitOp():
@@ -49,13 +50,11 @@ def test_addPythonUnitOp():
4950
uop.setName("example operation 1")
5051
uop.setInputStream(stream1)
5152

52-
stream2 = jneqsim.process.equipment.stream.Stream("stream2", uop.getOutputStream())
53-
5453
oilprocess = jneqsim.process.processmodel.ProcessSystem()
5554
oilprocess.add(stream1)
5655
oilprocess.add(uop)
57-
oilprocess.add(stream2)
5856

5957
oilprocess.run()
6058

61-
assert stream2.getPressure() == 2 * stream1.getPressure()
59+
# The outputstream gets the doubled pressure after run()
60+
assert uop.getOutputStream().getPressure() == 2 * stream1.getPressure()

0 commit comments

Comments
 (0)