Menu

Modify iteration and tolerance values from inside python code

2023-12-26
2023-12-30
  • Jonathan Motta

    Jonathan Motta - 2023-12-26

    Good afternoon,

    I'm working on a simple python script that executes two different "flash operations" from within the material stream itself using the Peng-Robinson 1978 property package. Some speciffic compositions haven't converged and others appeared to have some convergence issue due to high tolerance.
    On that note, I would like to know if it is possible to set a new tolerance and/or iteration value from inside the python code just as it's shown on the attached image from the DWSIM aplication. Also attached, is a code snipet out of context that exemplifies what I'm trying to accomplish (Importing the files from the DWSIM on my machine, setting values inside a material stream and calculating).

    Thanks in advance.

     
  • Daniel Medeiros

    Daniel Medeiros - 2023-12-30

    Hi Jonathan,

    import clr
    clr.AddReference('DWSIM.Interfaces')
    
    from DWSIM.Interfaces.Enums import FlashSetting
    
    pp.FlashSettings[FlashSetting.PTFlash_External_Loop_Tolerance] = "0.001"
    pp.FlashSettings[FlashSetting.PTFlash_Internal_Loop_Tolerance] = "0.001"
    pp.FlashSettings[FlashSetting.PHFlash_External_Loop_Tolerance] = "0.001"
    pp.FlashSettings[FlashSetting.PHFlash_Internal_Loop_Tolerance] = "0.001"
    
    pp.FlashSettings[FlashSetting.PTFlash_Maximum_Number_Of_External_Iterations] = "100"
    pp.FlashSettings[FlashSetting.PTFlash_Maximum_Number_Of_Internal_Iterations] = "100"
    pp.FlashSettings[FlashSetting.PHFlash_Maximum_Number_Of_Internal_Iterations] = "100"
    pp.FlashSettings[FlashSetting.PHFlash_Maximum_Number_Of_External_Iterations] = "100"
    
     
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.