I'm creating a heterogeneous catalytic Methanol reactor in my current simulation and attempting to display the chart containing Concentration and Temperature Profiles.
I've finished the program but two issues emerged.
All concentration curves are colored identically and therefore indistinguishable. I see no menu where I could adjust the colors or change other important things, like selectively plotting certain concentrations while ignoring others.
I can change the units of concentration by editing "System of Units" though, but unfortunately there is no option to choose molar fractions, which I would prefer in this case.
Another point that I want to mention is a tiny bug. The plotted graphs begin to visibly flicker once the Flowsheet is solved.
I tried both Classic and New UI (Version 5.7 Update 14) and got the same problems.
The file is linked below.
Download and install v5.8, you'll find a new Charts tab where you can view the concentration profile and configure the chart for your needs. To display molar fractions, you'll have to use a python script and the spreadsheet as described in the How-To Tutorial #3 in the User Guide.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
first things first, I tried out the new update and I have to congratulate you. The interface and design are much improved and when it comes to calculation times of scripted programs it is astonishingly quicker then 5.7.
Thanks a lot for your hard work.
Back to business.
The script you posted works and I get to simulate and manipulate the charts as wished.
But there's still an issue with the value output. As you can see in my other simulation, which is based on the following paper https://terpconnect.umd.edu/~nsw/chbe446/VandenBussche-syngas2MeOH.pdf , the molar fractions displayed on the floating tables of the flowsheet at reactor in- and outlet are nearly identical with the model. But the plotted graph gives almost diametrically different values, especially when I run the script various times or change the inlet streams
I guess it has to do with the way the script accesses molar fractions. How can the code be adjusted accordingly?
The compound names in the reactor are not necessarily the same as in the simulation, as there may be some inerts. We must get them from the CompoundConversions dictionary of the reactor, as they will be in the same order as the concentrations in the points vector.
The points vector in the reactor already includes the length as the first element, the following being the concentrations and the last two being the temperature and pressure:
Hello again Daniel,
perfect. Thank you for your help.
Just one tiny note. The code left out one component, but by slightly changing the range in three of the four for-loops, to include Methanol as the last object in the list 'cnames', the script correctly displays all concentration profiles I need.
importclrimportSystemclr.AddReference('System.Core')clr.ImportExtensions(System.Linq)reactor=Flowsheet.GetFlowsheetSimulationObject("REACTOR")profile=reactor.pointscnames=reactor.ComponentConversions.Keys.ToArray()n=cnames.CountSpreadsheet.Worksheets[0].Cells["A1"].Data="Reactor Length (m)"foriinrange(0,n):# instead of n-1Spreadsheet.Worksheets[0].Cells[0,i+1].Data=cnames[i]j=1forpointsetinprofile:Spreadsheet.Worksheets[0].Cells[j,0].Data=pointset[0]tmols=0foriinrange(1,n+1):# instead of ntmols+=pointset[i]foriinrange(1,n+1):# instead of nSpreadsheet.Worksheets[0].Cells[j,i].Data=pointset[i]/tmolsj+=1
Keep up your work on DWSIM, the frequent improvements and your support are greatly appreciated.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello Community,
I'm creating a heterogeneous catalytic Methanol reactor in my current simulation and attempting to display the chart containing Concentration and Temperature Profiles.
I've finished the program but two issues emerged.
All concentration curves are colored identically and therefore indistinguishable. I see no menu where I could adjust the colors or change other important things, like selectively plotting certain concentrations while ignoring others.
I can change the units of concentration by editing "System of Units" though, but unfortunately there is no option to choose molar fractions, which I would prefer in this case.
Another point that I want to mention is a tiny bug. The plotted graphs begin to visibly flicker once the Flowsheet is solved.
I tried both Classic and New UI (Version 5.7 Update 14) and got the same problems.
The file is linked below.
Could you please assist?
Download and install v5.8, you'll find a new Charts tab where you can view the concentration profile and configure the chart for your needs. To display molar fractions, you'll have to use a python script and the spreadsheet as described in the How-To Tutorial #3 in the User Guide.
Add and run this script:
Go to the Spreadsheet, select the entire data range and create a new chart frmo the range:
The generated chart can be fully configured by you.
Hello Daniel,
first things first, I tried out the new update and I have to congratulate you. The interface and design are much improved and when it comes to calculation times of scripted programs it is astonishingly quicker then 5.7.
Thanks a lot for your hard work.
Back to business.
The script you posted works and I get to simulate and manipulate the charts as wished.
But there's still an issue with the value output. As you can see in my other simulation, which is based on the following paper https://terpconnect.umd.edu/~nsw/chbe446/VandenBussche-syngas2MeOH.pdf , the molar fractions displayed on the floating tables of the flowsheet at reactor in- and outlet are nearly identical with the model. But the plotted graph gives almost diametrically different values, especially when I run the script various times or change the inlet streams
I guess it has to do with the way the script accesses molar fractions. How can the code be adjusted accordingly?
Last edit: Patrick Veiltl 2019-10-11
Hi Patrick,
My script has some errors.
The compound names in the reactor are not necessarily the same as in the simulation, as there may be some inerts. We must get them from the CompoundConversions dictionary of the reactor, as they will be in the same order as the concentrations in the points vector.
The points vector in the reactor already includes the length as the first element, the following being the concentrations and the last two being the temperature and pressure:
reactor.points = vector of vectors: [RL, C1, ..., Cn, T, P]
See this for the code part that creates and adds data to the points list: https://github.com/DanWBR/dwsim5/blob/windows/DWSIM.UnitOperations/Reactors/PFR.vb#L795
So, the correct script is this one:
You can link the script with the Object Calculation Finished event of the reactor so it is always executed after the reactor is calculated.
Regards
Daniel
Last edit: Daniel Medeiros 2019-10-11
Hello again Daniel,
perfect. Thank you for your help.
Just one tiny note. The code left out one component, but by slightly changing the range in three of the four for-loops, to include Methanol as the last object in the list 'cnames', the script correctly displays all concentration profiles I need.
Keep up your work on DWSIM, the frequent improvements and your support are greatly appreciated.