Menu

Run Calculation

2024-12-12
2024-12-17
  • Oliver Sacher

    Oliver Sacher - 2024-12-12

    Hello everybody,
    I am trying to use a DWSim-internal Python Script to adjust a splitter Unit-Operation. The calculation is running without any problems, but after calculating a new split-ratio and setting it to the splitter I can't solve/run the flowsheet again. By using "Flowsheet.RequestCalculation(None, False)" the warnings "Dynamic Mode is currently enabled" and "The calculator is busy, please wait..." occure, but nothing happens. By using "Flowsheet.SolveFlowsheet2()" I get the error "Traceback (most recent call last)".
    I noticed that everything seems to work well when I activate an "old" controllerblock. (Meanwhile it is replaced by a Script)
    Attached you can find my Flowsheet. I am using version 8.8.2. The relevant script is called MVRMassflow. I added it in a .txt-file as well.

     
    • Daniel Medeiros

      Daniel Medeiros - 2024-12-17

      Try calling

      RequestCalculationAndWait()
      

      so your code waits for the flowsheet to solve. You could also do

      RequestFlowsheetCalculation(None, True)
      

      but the first method is better as it will return a list of errors, if any.

       
  • Oliver Sacher

    Oliver Sacher - 2024-12-17

    Hello Daniel,
    thank you for your reply.
    Unfotunately both methods didn't work for me. I tried "Flowsheet.RequestFlowsheetCalculation(None, True)" as well as "Flowsheet.RequestCalculationAndWait()". Both times I get the error "Traceback (most recent call last)".
    When using "Flowsheet.RequestCalculation2(True)" and "Flowsheet.RequestCalculation3(None, True)" Warning is again "Dynamic Mode is currently enabled" and "The calculator is busy, please wait..." and nothing happens.

     
    • Daniel Medeiros

      Daniel Medeiros - 2024-12-17

      I saw your script. I never expected someone to do calls to the flowsheet solver right after it has finished... I added the "not busy" setter right after running the solver finished scripts!

      You can try this

      import clr
      
      clr.AddReference("DWSIM.GlobalSettings")
      
      GlobalSettings.Settings.CalculatorBusy = False
      

      at the top of your script.

       
  • Oliver Sacher

    Oliver Sacher - 2024-12-17

    It is because adjustment of the split ratio requieres calculation of the whole flowsheet again. I also tried to use the same script after calculating the last Stream, so before the solver finished, but the same problems occured. Maybe you know another way expect from using an external python-script for DWSIM-Automation. This would have been my next try.

    However, it worked the way you described in your previous post with one small adjustment:

    import clr
    clr.AddReference("DWSIM.GlobalSettings")
    from DWSIM.GlobalSettings import Settings
    Settings.CalculatorBusy = False
    

    I used this and the following method:

    Flowsheet.RequestCalculation()
    

    Thank you very much!

     
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.