First of all, thanks for this wonderful piece of software!!!
Now my issue:
I have just started using the IronPython scripting facility within DWSIM.
My code uses my custom DLL to perform a gas membrane separation simulation.
This all works fine (I have implemented it in the Excel UO where it functions fine, albeit somewhat slow).
As input to my model I (dynamically) need selectivity values for each compound in the feed stream.
As the feed may vary in terms of number and type of compounds, I would like to be able to enter these values in the UI (as we can do with Excel UO).
This would require a dynamic Input variable list.
I really have no clue how to do that.
Any idea's?
Perhaps other (better) ways to accomplish what I want?
My basic scripting example (functional, but not complete right now) shows the 'issue' at line 33.
For testing purposes I manually added the 'alfa' values here.
Well, if you look at the attached jpeg you can see the input variables from the Excel UO on the left and the input variables of the IronPython script at the right.
In case of the Excel UO (see attached "GSM3.xlsm"): The compound names are sent to Excel so I can construct parameters there, such as 'Carbon dioxide sel'. These input parameter are then read by my XLL which performs the simulation and returns the output stream compositions as well as some output information.
In the case of the Script UO: I can predefine only some input variables which are not related to the feed composition. I could put the addtional needed -feed compound related- data in each script, but this is cumbersome and error prone.
* For the user of the system it would be preferrable to be able to enter such variables directly in the 'Scripting Variables' input area.
So basically my question is this:
How can I get the required, feed compound related, input variables into my simulation?
Is there perhaps a way to cleverly use the DWSIM spreadsheet for this?
Note that there may be many Script UO objects in one Flowsheet...
Some example projects I observed showed the strong possibilities of the 'general' scripting tools, as well as the powerful debug features.
I already could add input variables by means of scripting code.
Basically what I would need is to call my script (adding input variables based on feed compound names) when the feed composition is changed.
Or, perhaps, when the flowsheet is loaded.
This script would then run before the 'Script UO script', automatically populating the input variable entries.
Would that be possible?
And does this make sense? (sorry, I am a real beginner with this scripting software)
Greetings,
Auke
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You have access to the connected inlet streams through the ims1, ims2, ims3 (...) variables, then you can read all its properties on your script. What is the property that you need to read from them?
Also, it is possible to create a general script using the script manager and then link it to the simulation opened event, which would then make it run after the flowsheet is loaded.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for your help.
For now I solved it by creating a general script which needs to run once (when the CustomUO objects have been connected to their respective input streams).
The script then retrieves only the CustomUO objects and fills the input parameter list with static values as well as values related to the stream components.
This works well.
The user can then simply change the values in the GUI and run the simulation.
Greetings,
Auke
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The code -obviously- allows setting of custom stream properties and an easy way of entering the values.
What I needed is similar:
Each component has an extra property (membrane flux selectivity) which needs to be set -and can be played with- before solving the flowsheet.
I fixed it by dynamically adding these parameters as input parameters for the CustomUO objects...
Greetings,
Auke
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
First of all, thanks for this wonderful piece of software!!!
Now my issue:
I have just started using the IronPython scripting facility within DWSIM.
My code uses my custom DLL to perform a gas membrane separation simulation.
This all works fine (I have implemented it in the Excel UO where it functions fine, albeit somewhat slow).
As input to my model I (dynamically) need selectivity values for each compound in the feed stream.
As the feed may vary in terms of number and type of compounds, I would like to be able to enter these values in the UI (as we can do with Excel UO).
This would require a dynamic Input variable list.
I really have no clue how to do that.
Any idea's?
Perhaps other (better) ways to accomplish what I want?
My basic scripting example (functional, but not complete right now) shows the 'issue' at line 33.
For testing purposes I manually added the 'alfa' values here.
I include my test project for your reference.
Many thanks and greetings,
Auke Nauta
Hi,
What do you mean with entering the values in the UI?
Regards
Daniel
Hi Daniel,
Well, if you look at the attached jpeg you can see the input variables from the Excel UO on the left and the input variables of the IronPython script at the right.
In case of the Excel UO (see attached "GSM3.xlsm"):
The compound names are sent to Excel so I can construct parameters there, such as 'Carbon dioxide sel'.
These input parameter are then read by my XLL which performs the simulation and returns the output stream compositions as well as some output information.
In the case of the Script UO:
I can predefine only some input variables which are not related to the feed composition.
I could put the addtional needed -feed compound related- data in each script, but this is cumbersome and error prone.
* For the user of the system it would be preferrable to be able to enter such variables directly in the 'Scripting Variables' input area.
So basically my question is this:
How can I get the required, feed compound related, input variables into my simulation?
Is there perhaps a way to cleverly use the DWSIM spreadsheet for this?
Note that there may be many Script UO objects in one Flowsheet...
Thanks for you help,
Auke
Just a bit of extra info:
Some example projects I observed showed the strong possibilities of the 'general' scripting tools, as well as the powerful debug features.
I already could add input variables by means of scripting code.
Basically what I would need is to call my script (adding input variables based on feed compound names) when the feed composition is changed.
Or, perhaps, when the flowsheet is loaded.
This script would then run before the 'Script UO script', automatically populating the input variable entries.
Would that be possible?
And does this make sense? (sorry, I am a real beginner with this scripting software)
Greetings,
Auke
You have access to the connected inlet streams through the ims1, ims2, ims3 (...) variables, then you can read all its properties on your script. What is the property that you need to read from them?
Also, it is possible to create a general script using the script manager and then link it to the simulation opened event, which would then make it run after the flowsheet is loaded.
If you want to add new variables, you can use the ExtraProperties container to store them.
Check this: https://github.com/Spogis/Psychrometry
I believe that it has everything you need!
Hi Daniel,
Thanks for your help.
For now I solved it by creating a general script which needs to run once (when the CustomUO objects have been connected to their respective input streams).
The script then retrieves only the CustomUO objects and fills the input parameter list with static values as well as values related to the stream components.
This works well.
The user can then simply change the values in the GUI and run the simulation.
Greetings,
Auke
Hi,
Having briefly looked at https://github.com/Spogis/Psychrometry I must say this is powerful code and is really useful for learning experiences!
The code -obviously- allows setting of custom stream properties and an easy way of entering the values.
What I needed is similar:
Each component has an extra property (membrane flux selectivity) which needs to be set -and can be played with- before solving the flowsheet.
I fixed it by dynamically adding these parameters as input parameters for the CustomUO objects...
Greetings,
Auke