Skip to main content
1-Visitor
March 2, 2018
Question

Complex DAE-System, faster computation

  • March 2, 2018
  • 2 replies
  • 5221 views

Hello,

 

I write a complex model of a batch reactor. Main goal is to model a thermal runaway of a reaction (adiabtic reactor). In a further step I want to predict the kinetic parameters of the reaction, like k0_1,k0_2, Ea_1, Ea_2 and reaction enthalpie. Therefore I will write a least-square method with minimize or minerr. The unlinear regression needs several measured temperature curves an the temperature curve of the model. The regression part is not implemented yet.

My first idea was to write an odesolve function, so that I can solve the DAE-system for different reactor volumes an initial guesses like mass and Temeprature (The measured curves, have different volumes, startmasses and temperatures). Therefore i write a function Startbed. Another part are variable component data, like density, heat capacities etc. This functions interpolate between different temperature steps. Also there ist an UV-Flash calculation. I need it to predict the mass in gas and liquid phase (phase behaviour calculation) and others values. UV means a flash at a given internal energy and volume. In a solve block to solve the DAE-system, I call the UV-Flash function in every time-step (integration step). This function predicts iterative the composition of gas and liquid phase, temperature, and pressure. The initial guesses for that iterative prediction are the values of the previous integration step. TheODE's consits of mass balances of the components and an energy balance in an internal energy form. I hope the description help to understand the Mathcad file.

 

Now I have two questions:

 

1. The calculation ist very slow. I have to choose small integration steps, because the runaway leads to very abrupt temperature increase at a specific time. Also i call the UV-flash calculation function in every time step and the interpolate function of the chemical data of the components. I think this slows down the computation, too. Is there a way to make the calculation faster?

 

2. Sometimes the solution is not found. I think it is because abrupt temperature increase (stiff system). Smaller integration steps lead to an even slower calculation. Is there a possibilty two use another solver like stiffr or stiffb? Maybe than I can use bigger integration steps. But how can  I calculate the jacobian in this case?

 

Best regards,

Fabian Görlich

2 replies

24-Ruby IV
March 2, 2018

May be this book help you

Chemical Kinetics with Mathcad and Maple

We have use hybrid methods: numeric and symbolic calculations. For faster calculations too!

1-Visitor
March 2, 2018

Fabian,
Unfortunately I can not open the file Mathcad 4.0. Please attach the file in .pdf-format.

fgörlich1-VisitorAuthor
1-Visitor
March 2, 2018

Here is a pdf file (Update, with the full code)

21-Topaz II
March 2, 2018

Hi,

Small suggestion:- assigning the last element of a vector sets the memory to the final size in one go.

If you don't do this the memory for the vector needs to expand at every assignment during the loop and this is not efficient.

 

I  Assign.jpg