Skip to content

add unitop #279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 6, 2024
Merged

add unitop #279

merged 7 commits into from
Aug 6, 2024

Conversation

EvenSol
Copy link
Collaborator

@EvenSol EvenSol commented Aug 4, 2024

Framework for adding new unit operations in python code (for fast testing before full implementation in Java). See how to implement Java interfaces from Python:
https://jpype.readthedocs.io/en/latest/quickguide.html#implements-and-extension

Eg. given in test:


class ExampleCompressor(unitop):
    def __init__(self):
        super().__init__()
        self.name = ""
        self.inputstream = None
        self.outputstream = None

    def setInputStream(self, stream):
        self.inputstream = stream
        self.outputstream = stream.clone()

    def getOutputStream(self):
        return self.outputstream

    @JOverride
    def run(self):
        fluid2 = self.inputstream.getFluid().clone()
        fluid2.setPressure(fluid2.getPressure() * 2.0)
        self.outputstream.setFluid(fluid2)
        self.outputstream.run()

The code can be tested:


   fluid1 = fluid("srk")  # create a fluid using the SRK-EoS
    fluid1.setTemperature(30.0, "C")
    fluid1.setPressure(1.0, "bara")
    fluid1.addComponent("n-pentane", 1.0, "kg/sec")
    fluid1.addComponent("n-hexane", 1.0, "kg/sec")
    fluid1.setMixingRule(2)

    stream1 = jNeqSim.processSimulation.processEquipment.stream.Stream(fluid1)
    stream1.setFlowRate(30000, "kg/hr")
    stream1.run()
    
    uop = ExampleCompressor()
    uop.setName('example operation 1')
    uop.setInputStream(stream1)
    uop.run()

    stream2 = jNeqSim.processSimulation.processEquipment.stream.Stream(uop.getOutputStream())
    stream2.run()

    assert stream2.getPressure()==2*stream1.getPressure()

@EvenSol EvenSol requested a review from Sviatose August 4, 2024 15:29
@EvenSol
Copy link
Collaborator Author

EvenSol commented Aug 4, 2024

Similar functionality could be implemented for measurement devices

@EvenSol
Copy link
Collaborator Author

EvenSol commented Aug 5, 2024

Similar functionality could be implemented for measurement devices

Done now

@EvenSol EvenSol merged commit 9d0c7cf into master Aug 6, 2024
6 checks passed
@EvenSol EvenSol deleted the uniptop-and-tests branch August 6, 2024 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant