Menu

Adiabatic Compression Loop using python script

2016-08-25
2016-09-10
  • Marcos Fernandez Gomes

    Hello,

    I have a csv file with thousands ambient air of temperature, humidity and pressure. For each of these pair of values I want to calculate the required energy for an adiabatic compression.

    I have created a flowsheet that successfully calculates the values for one condition.

    I have then decided to try the python script to change the current values defined in the flowsheet and recalculate the system.

    Compressor.SetPropertyValue("PROP_CO_0",400000)
    Compressor.SaveData()

    Solver.CalculateObject(Flowsheet,Compressor.Nome)
    print("Energy: " + str(Compressor.GetPropertyValue("PROP_CO_3")))

    But no matter the value I set for the PROP_CO_0, the value printed is the same.

    Can anyone help me? What am I doing wrong?

    Thanks

     
  • Daniel Medeiros

    Daniel Medeiros - 2016-08-26

    Are you using DWSIM 4? Can you attach a sample simulation?

     
  • Marcos Fernandez Gomes

    I have tried both DWSIM4 and 3.7. I have attached a the dwsim 3.7 project file.

    Thank you

     
  • Gustavo León

    Gustavo León - 2016-08-27

    Hello Marcos,

    Are you trying to calculate the Compressor with different Pressure Drop values or trying different compositions for the stream?

     
  • Daniel Medeiros

    Daniel Medeiros - 2016-08-28

    Hi Marcos,

    After getting Update 15 for DWSIM 4.0 you should be able to run the following script. Please note that the API has changed a lot from DWSIM 3 to 4, I'm uploading a new documentation to the server right now: http://dwsim.inforside.com.br/api_help/index.html

     
  • Daniel Medeiros

    Daniel Medeiros - 2016-08-28

    Please note that you don't need to call SaveData() as it is only called during the file saving procedure. It will just return a bunch of xml nodes that don't make sense when separated from the rest of the data.

     
  • Marcos Fernandez Gomes

    Thank you very much for your support. The file I have attached earlier is working correctly in 3.7.

    In DWSIM4, when I call "Solver.CalculateObject(Flowsheet,Compressor.Nome)" I get the error: AttributeError: 'Compressor' object has no attribute 'Nome'

    By chnaging 'Nome' to 'Name' it works in DWSIM4:)

    Thank you very much for the support, and congractulations for the software. It is a great tool.

    Can you tell me if my approach is the best or is there other better way to do it?

    thanks

     
  • Daniel Medeiros

    Daniel Medeiros - 2016-08-30

    You can run in DWSIM 4 the modified file that I've attached before, I believe that it is somewhat "optimized"...

    Instead of calling Solver.CalculateObject() you can use the new Flowsheet.RequestCalculation() method. If you send the object as an argument, it will calculate everything after the object, including itself. If no argument is sent, the flowsheet will be recalculated on its entirety.

     

    Last edit: Daniel Medeiros 2016-08-30
  • Marcos Fernandez Gomes

    I have made some changes to the dwsim4 file. I have attached both dwsim and csv example file.

    I have noticed that in the DWSIM4 we can define and access the object properties directly, instead of using the SetPropertyValue method. This is great, however I could not found a list of the properties from the objects. Is there any API reference for the DWSIM4?

    Currently I am able to calculate each line in about a second. I will have to use csv files with some houndred of thousands of values....

    Is there any other faster way to do this in DWSIM?

    One again thank you very much for the help

     
  • Marcos Fernandez Gomes

    In DWSIM3 we could use the SetPropertyValue method to define new values and units of the property.

    In DWSIM4 if we use direct acess to the property, is there any way to define the untis? Or should we use the SetPropertyValue like in DWSIM3?

    thanks

     
  • Marcos Fernandez Gomes

    Thank you, previously I haven't found the MaterialStream class in the tree. It was really usefull.

    Which is the best and fastest way to create a simulation system and feed it with the csv values? Is the ironpython script the best way to do it? Or is there other options I could use to get it done faster?

    thank you

     
  • Daniel Medeiros

    Daniel Medeiros - 2016-09-10

    If the simulation process doesn't change, an ironpython script is the fastest way. Read the csv contents to an array and use a for loop to update, calculate and retrieve the results.

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.