Menu

Python Script for Advanced Kinetics

2021-04-30
2022-12-29
  • Lukas Hayer

    Lukas Hayer - 2021-04-30

    Hi, I am trying to use the Script Manager to create a kinetic reaction for a methanol synthesis. The corresponding file is attached below. If I want to solve the Flowsheet DWSIm throws an EOF and ode solver error. Now im wondering if I am using the right syntax. More specific, do I just have to use the variables Ri and Pi or do I have to import respectively calculate the partial pressure myself. Because If I am simulating the reaction via the rate expressions it works perfectly fine.
    Could anyone help me? I attached my DWSIM model below.
    Thanks in advance.
    Lukas

     
  • Luca Finardi

    Luca Finardi - 2021-04-30

    Hi Lukas,

    you get a EOF error because your equation for r has some missing brackets.
    In your scripts you don't need to import Ri and Pi from the inlet stream as the partial pressures are directly passed, so use in the equations T, P, R1, R2 ... P1 P2.

    I run the model, but after quite long it failed ... so a closer look to the script expressions is needed.

    Hope it helps.

    Luca

     
    • Mykhailo Vilboi

      Mykhailo Vilboi - 2022-12-25

      Hello Luca!
      Could you please help me with similar issue?
      I am using Lukas's script as a basis to learn how to use DWSIM, and I am encountering issue with naming of variables. DWSIM states that T, or, i presume, P1,P2... are not defined.
      Please see the file attached.

      P.S. That is when I am running debugger, otherwise everything seems to run smoothly.

       

      Last edit: Mykhailo Vilboi 2022-12-25
      • et3gti

        et3gti - 2022-12-29

        Mykhailo,

        I am experiencing the same trouble.

        Did you figure out a different way to access reactor variables?

        Thanks

         
      • Daniel Medeiros

        Daniel Medeiros - 2022-12-29

        You can't run this script in debug mode because the variables are set by the reactor when it is being calculated. You can always use print() or Flowsheet.WriteMessage() to display something in the Log Panel.

         
        • et3gti

          et3gti - 2022-12-29

          Thank you so much Daniel. I was stuck on this for a long time.

          For what it's worth, the print functio doesnt work for me but the Flowsheet.WriteMessage(str(var)) does.

           
          👍
          2
  • Lukas Hayer

    Lukas Hayer - 2021-05-11

    Thanks a lot Luca! The flowsheet was solved even faster as with the rate expressions. Altough I'm not geeting excactly the same 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.