Solve Engineering Balance Equations in Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ธ.ค. 2024

ความคิดเห็น • 42

  • @joan3338
    @joan3338 2 ปีที่แล้ว +4

    Thank you for doing this. This is great. I wish I had started to learn python sooner, seeing the importance that it has nowadays. I'm doing a masters on reactor engineering, and now I see how much they are linked together.

  • @nano7586
    @nano7586 6 ปีที่แล้ว +12

    Biotechnology + Python = Success

  • @kevinhernandezmonzalvo5539
    @kevinhernandezmonzalvo5539 3 ปีที่แล้ว +3

    Hello Sir. Chemical Engineering student here. I’ve been watching your videos looking for an answer to my problem. Hope you can help me! I have a reactor wirh 3 simultaneous reactions. I have some additional information about the selectivity: they give me 3 different equations that implies the value of some species concentrations ratios and conversion of the limitant reactant. I know that I can solve the mole balance of my reactor because when I calculate the degrees of freedom I find its value is zero.
    My matrix to solve would be the mole balance for each species involved in the reactions. I can solve it by hand using those extra equations of selectivity and conversion just by replacing and doing the basic algebra, but I want to program it on Python. I just can’t find the way to tell Python to consider the linear extra equations that they give me along the mole balance matrix that represent a linear equation system. I’ve tried with Gekko, numpy, linalg without success.
    Thank you for your time.

    • @apm
      @apm  3 ปีที่แล้ว +1

      I'd be glad to give some suggestions. Please post the problem and your attempt to solve it on StackOverflow with tag gekko: stackoverflow.com/questions/tagged/gekko

  • @chachan2889
    @chachan2889 ปีที่แล้ว +1

    Dear professor,
    I have some problems with the equilibrium equations. The chain rules make sense to me. In the slide set for the energy equation it says (m*cp* dTdt) on the left side. But doesn't this only apply if the mass or density and volume are constant. Otherwise I don't understand how the chain rule should work here. In other words, am I correct that instead of "(m*cp* dTdt)", the term "(rho * cp* d(VT)dt)" should be in the slides?

    • @apm
      @apm  ปีที่แล้ว

      Please see this problem and solution for an example of how to use the chain rule when accumulation mass and concentration both vary: apmonitor.com/pdc/index.php/Main/DeriveBalanceEquations

  • @hermanhaloho8251
    @hermanhaloho8251 ปีที่แล้ว +1

    Sir, for command odeint not available right now, and change with solve_ivp. Could you please to make another video regarding this exercise? Thankyouuu

    • @apm
      @apm  ปีที่แล้ว

      Great idea. solve_ivp uses the ODEINT algorithm for one of the options.

  • @dafirayoub5187
    @dafirayoub5187 3 ปีที่แล้ว +1

    in the energy balance you must use the power instead of the work it have a dimension of energy over time . (same thing for Q as well)

    • @apm
      @apm  3 ปีที่แล้ว +1

      Energy / time is the correct dimension for continuous processes. Here is more information on energy balances: apmonitor.com/pdc/index.php/Main/PhysicsBasedModels If you are modeling a batch process then time isn't important.

    • @dafirayoub5187
      @dafirayoub5187 3 ปีที่แล้ว

      Enery/time is the correct dimension indeed. but work and heat have dimension of enery, so that's why i think we should use a power wich has the correct dimension . am I wrong?

  • @samsont81
    @samsont81 ปีที่แล้ว +1

    Thank you very much, your derivations simplified the task. What do I do in the first instance where density is not constant and if there is a change in density due to heat?
    Really appreciate your videos.

    • @apm
      @apm  ปีที่แล้ว +1

      You’ll need to use the chain rule as shown in this exercise: apmonitor.com/pdc/index.php/Main/PhysicsBasedModels

  • @luizchaves1968
    @luizchaves1968 4 ปีที่แล้ว +1

    Very nice! Good exercise for beginners

  • @AJ-et3vf
    @AJ-et3vf 3 ปีที่แล้ว +1

    Awesome video sir. Thank you!

  • @Enrique.GarciaFranco
    @Enrique.GarciaFranco 5 ปีที่แล้ว +2

    Dear developer:
    May I ask you what numerical method is the integrator using to solve this ODE problem?
    Thanks

    • @apm
      @apm  5 ปีที่แล้ว +2

      Here is the source code: apmonitor.com/pdc/index.php/Main/PhysicsBasedModels It uses ODEINT (an ode integrator that uses a Runga Kutta method for integration). See apmonitor.com/pdc/index.php/Main/SolveDifferentialEquations
      You can also use Python Gekko: apmonitor.com/pdc/index.php/Main/PythonDifferentialEquations

    • @Enrique.GarciaFranco
      @Enrique.GarciaFranco 5 ปีที่แล้ว +3

      Your work is absolutely amazing, while being open access. I would like to wish you all the best and express my gratitude too.

  • @saraderouiche
    @saraderouiche 4 ปีที่แล้ว +1

    Please, where find cour about Mpc linear of cstr , and elso typicl obtain linear plant model with adaptive mpc?
    Thank u🎆

    • @apm
      @apm  4 ปีที่แล้ว

      Here is a course on MPC with many examples of linear and adaptive MPC: apmonitor.com/do

  • @doraemon551
    @doraemon551 4 ปีที่แล้ว +1

    Dear professor,
    What is the difference between solving odeint using just t and ts = [t[i],t[i+1]] or ts = [t[i-1],t[i]]? Thanks a million.

    • @apm
      @apm  4 ปีที่แล้ว

      They are the same if the times are uniform and there is no "t" in the model. You could also use [0,10/99] or [0,0.10101010101] and get the same answer with t=np.linspace(0,10,100). If I had used t=np.linspace(0,10,101) it would have [0,0.1] time steps at 11:00 in the video.

  • @special1_28
    @special1_28 4 ปีที่แล้ว +3

    What an excellent Tutorial.
    Hello Professor, I understood everything until I got to this point:
    V[i+1] = y[-1] [0]
    Ca[i+1] = y[-1] [1]
    T[i+1] = y[-1] [2]
    Please kindly explain more.
    Thank you.

    • @apm
      @apm  4 ปีที่แล้ว +4

      It is storing the last value of the integration step from ODEINT in individual arrays for plotting. More info on differential equation solutions is at apmonitor.com/pdc/index.php/Main/SolveDifferentialEquations

    • @special1_28
      @special1_28 4 ปีที่แล้ว +2

      @@apm Thank you for your timely response. I know that it was intended to store the previous value of the integration steps, however, my doubt is the introduction of double brackets that contains -1 each and 0,1, and 2 respectively at the RHS.

    • @apm
      @apm  4 ปีที่แล้ว +2

      -1 means the last row. If you put -2 it would be the second to last row. The second bracket is for the column and is 0, 1, 2 for the 1st, 2nd, and 3rd column. There is more on lists and Numpy arrays here: apmonitor.com/che263/index.php/Main/PythonArrays

    • @doraemon551
      @doraemon551 4 ปีที่แล้ว +2

      @@apm OMG, you're the best!

  • @googlegoogle1610
    @googlegoogle1610 2 ปีที่แล้ว +1

    # Inlet Volumetric Flowrate (L/min)
    qf = np.ones(len(t))* 5.2
    qf[50:] = 5.1
    # Outlet Volumetric Flowrate (L/min)
    q = np.ones(len(t))*5.0
    please, how did you get 5.2,5.1, and 5???

    • @apm
      @apm  2 ปีที่แล้ว

      qf is the feed concentration and is 5.2 initially and then drops to 5.1 at cycle 51. The variable q is the outlet concentration and is initially equal to 5.0. It rises faster with the feed of 5.2 and then levels out at 5.1 with the reduction in feed concentration.

  • @jpz6072
    @jpz6072 5 ปีที่แล้ว +1

    Great example. Thanks!

  • @asifnizamani7513
    @asifnizamani7513 6 ปีที่แล้ว +1

    sir can i make snap shot of your video

    • @apm
      @apm  6 ปีที่แล้ว +1

      search for snipping tool in Windows. You can also find these notes at apmonitor.com/pdc

    • @asifnizamani7513
      @asifnizamani7513 6 ปีที่แล้ว

      thanks sir