Dear all, dear Daniel,
I have started program within the Script Editor (IronPython) to control better the simulation.
Here my questions:
1. how can I access the pipe object to define for example the environmental temperature (Heat transfer calculation) ? I have tried to code:
printdir(myPipe)
but cannot see such a property
2. can a built a custom splitter/mixer with more than 3 streams for inlet/outlet respectively? I have just a steam flow splitting in more pipes, I would not use more indented mixers
3. Is there a way to control better the object of the script? I use only dir() or type(), but it is a bit frustrating and not find any help googling around.
If you're on the Classic UI, if you run the script in Debug mode and add a breakpoint somewhere, you'll get a list of all objects available to the script and their properties:
The Pipe Segment object has a Profile property which holds the hydraulic profile and a ThermalProfile one to hold the thermal profile. If you check the source code for the Pipe Segment Editor on the Cross-Platform UI you'll understand how to work with them:
With the latest versions you have a "Inser Snippet" menu in the Script Manager, where you'll find a sample code for the mixer which you can easily extend to more than 3 inlets.
Regards and merry xmas for you too. 😊
Daniel
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks,
I was able to add a connector with .InputConnectors.Add() feature of GraphicObject entity.
importclrclr.AddReference('DWSIM.MathOps')clr.AddReference('DWSIM.UnitOperations')clr.AddReference('DWSIM.Interfaces')fromDWSIMimport*fromDWSIM.Thermodynamics.Streamsimport*fromDWSIM.UnitOperationsimport*fromDWSIM.MathOps.MathEximport*fromSystemimport*fromSystem.Collections.Genericimport*# gets the mixer objectmixer=Flowsheet.GetFlowsheetSimulationObject('MIX-009')newIconn=mixer.GraphicObject.InputConnectors[0]newIconn.ConnectorName="Inlet 7"mixer.GraphicObject.InputConnectors.Add(newIconn)
However, I run the script , the MIX-009 correctly in debug shows the new connector within the list of InputConnectors, but on the flowsheet I cannot see the input handles to add the new mass streams as with the other mixers (i would like to add by hand new streams).
Many thanks in advance
Last edit: Mario Cilento 2019-12-23
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This won't work reliably as DWSIM expects the mixer to have only 3 inlet streams, so the editor will have only three stream selectors and won't show the additional ones that you are adding this way.
What you should do is to use the Python Script Unit Operation and write the mixer code in python (you already have it as a code snippet), this way you can modify the code to support up to 6 inlet streams which is the maximum amount that the Python UO supports.
Regards
Daniel
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you.
The issues with Python Script UO is that every time I click on "Open Python Script Editor" I get this error, and don't know how to go ahead:
Objectreferencenotsettoaninstanceofanobject.
Are there any tutorials on Python UO?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I will look better for tutorials on Python-UO. For now I have my custom-splitter with 2 outlet streams, programmed with linked python-code when calculation on the block starts.
The code works even though the flow rate is not halved (all the streams have the same flow rate, energy balance not respected).
I.e. I set 5 kg/s of steam as inlet and after flowsheet is calculated I get 2.5 kg/s as inlet, 2.5 kg/s as 1st outlet, and 2.5 kg/s as 2nd outlet. Quite weird, since I set the flux be the half at the exit!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello Daniel, it worked greatfully.
Here to signal you two bugs on pipe-segment:
1. when Thermal Profile is set to 'evaluate overall HTC' why there is not simply the input of outer fluid heat transfer coefficient (in W/m2/K). moreover with stone as outer fluid (maybe even with other fluids) the higher the velocity the lower the heat exchange (suspicious error)
2. length of elbow 180° is a fixed value and does not allow to enter a user defined value. why this?
👍
1
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry for posting here, but I didn't know elsewhere to post bugs. Please write down somewhere in the forum or add a bug fixing section to converge there all the topics about.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dear all, dear Daniel,
I have started program within the Script Editor (IronPython) to control better the simulation.
Here my questions:
1. how can I access the pipe object to define for example the environmental temperature (Heat transfer calculation) ? I have tried to code:
but cannot see such a property
2. can a built a custom splitter/mixer with more than 3 streams for inlet/outlet respectively? I have just a steam flow splitting in more pipes, I would not use more indented mixers
3. Is there a way to control better the object of the script? I use only dir() or type(), but it is a bit frustrating and not find any help googling around.
Thank you in advance for the attention.
Hi Mario,
If you're on the Classic UI, if you run the script in Debug mode and add a breakpoint somewhere, you'll get a list of all objects available to the script and their properties:
The Pipe Segment object has a Profile property which holds the hydraulic profile and a ThermalProfile one to hold the thermal profile. If you check the source code for the Pipe Segment Editor on the Cross-Platform UI you'll understand how to work with them:
https://github.com/DanWBR/dwsim5/blob/windows/DWSIM.UI.Desktop.Editors/UnitOperations/PipeHydraulicProfile.cs
https://github.com/DanWBR/dwsim5/blob/windows/DWSIM.UI.Desktop.Editors/UnitOperations/PipeSection.cs
https://github.com/DanWBR/dwsim5/blob/windows/DWSIM.UI.Desktop.Editors/UnitOperations/PipeThermalProfile.cs
Regards
Daniel
Hello Daniel,
thank you for your kind answer. I infact was on version 5 of the software, version 5.8 has this amazing debugging feature!
Regarding the multiple switch/mixer? Can you give me same advice to model one with more than 3 inputs/outputs?
Warm regards and happy xmas
With the latest versions you have a "Inser Snippet" menu in the Script Manager, where you'll find a sample code for the mixer which you can easily extend to more than 3 inlets.
Regards and merry xmas for you too. 😊
Daniel
Thanks,
I was able to add a connector with .InputConnectors.Add() feature of GraphicObject entity.
However, I run the script , the MIX-009 correctly in debug shows the new connector within the list of InputConnectors, but on the flowsheet I cannot see the input handles to add the new mass streams as with the other mixers (i would like to add by hand new streams).
Many thanks in advance
Last edit: Mario Cilento 2019-12-23
This won't work reliably as DWSIM expects the mixer to have only 3 inlet streams, so the editor will have only three stream selectors and won't show the additional ones that you are adding this way.
What you should do is to use the Python Script Unit Operation and write the mixer code in python (you already have it as a code snippet), this way you can modify the code to support up to 6 inlet streams which is the maximum amount that the Python UO supports.
Regards
Daniel
Thank you.
The issues with Python Script UO is that every time I click on "Open Python Script Editor" I get this error, and don't know how to go ahead:
Are there any tutorials on Python UO?
Try opening DWSIM.exe directly from the installation folder.
As for the tutorials, there are some samples included with DWSIM and you can check the topics on this forum for more help.
I will look better for tutorials on Python-UO. For now I have my custom-splitter with 2 outlet streams, programmed with linked python-code when calculation on the block starts.
The code works even though the flow rate is not halved (all the streams have the same flow rate, energy balance not respected).
I.e. I set 5 kg/s of steam as inlet and after flowsheet is calculated I get 2.5 kg/s as inlet, 2.5 kg/s as 1st outlet, and 2.5 kg/s as 2nd outlet. Quite weird, since I set the flux be the half at the exit!
You should link it to the calculation object ended event, as this code will run before the actual calculation code runs (too).
Hello Daniel, it worked greatfully.
Here to signal you two bugs on pipe-segment:
1. when Thermal Profile is set to 'evaluate overall HTC' why there is not simply the input of outer fluid heat transfer coefficient (in W/m2/K). moreover with stone as outer fluid (maybe even with other fluids) the higher the velocity the lower the heat exchange (suspicious error)
2. length of elbow 180° is a fixed value and does not allow to enter a user defined value. why this?
Sorry for posting here, but I didn't know elsewhere to post bugs. Please write down somewhere in the forum or add a bug fixing section to converge there all the topics about.
Hi Mario, please open a new ticket here: https://sourceforge.net/p/dwsim/tickets/