Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.

Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

1 function, 2 solving methods, 2 different answers, Math problem or comsol problem?

Please login with a confirmed email address before reporting spam

Good day dear colleagues!

I have a problem with solving a function that describes a chemical reaction and I would gladly hear your opinions about this issue.

I model a certain process as a batch type reaction (constant volume):
dCa/dt = -k * Ca. If this is integrated analytically I get: Ca = Ca0 * exp(-k*t) and the flux of matter is then just the change: dCa/dt.
k Is defined as: k0 * exp( -E_A / R * T)

If I model this (as mass, using constant volume and constant molar mass), I get two different equations:

1] expression for mass left and mass flux, modeled as variables:
m_H2O_l_kg = Moisture_init_wtkg_zone*exp(-k_H2O*t)
m_H2O_fluxie_kgs = -d(m_H2O_l_kg,t)

2] function directly modeled using a PDE (general form)
dm_H2O/dt = -k_H2O*m_H2O,
initial mass = Moisture_init_wtkg_zone, initial flux = -k_H2O * Moisture_init_wtkg_zone

The problem is that I expect the results to be exactly the same, but they are quite different!
I included the plots and a very simple model using these functions.

Could anyone explain the difference? What am I missing here? (And which method is actually right?)

Many thanks for any input in advance. :)
Kind regards,

Ray


4 Replies Last Post Mar 19, 2012, 11:50 a.m. EDT
Nagi Elabbasi Facebook Reality Labs

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Mar 19, 2012, 9:27 a.m. EDT
The solution to dCa/dt = -k * Ca that you provided is only valid if k is constant, and in your case it is a function of a time varying T.

Nagi Elabbasi
Veryst Engineering
The solution to dCa/dt = -k * Ca that you provided is only valid if k is constant, and in your case it is a function of a time varying T. Nagi Elabbasi Veryst Engineering

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Mar 19, 2012, 9:45 a.m. EDT

The solution to dCa/dt = -k * Ca that you provided is only valid if k is constant, and in your case it is a function of a time varying T.

Dear Nagi, thanks for your reply.
I figured it had something to do with the k, but the results were both believable so it was difficult to discern what went wrong. So, you say because the function is integrated you cannot hav a varying k?
So this means that the PDE solution is indeed the right one and this method the correct one, true?
The PDE result does seem more logical. The flux increases since the T and therefore the k increase, but then the amount left decreases and a peak is reached. Then the T and therefore the k are constant, so the mass flux decrease is only caused by decrease of mass, which is relatively slow. This seems to be the description of the PDE's result.

Let me know if there are any (small ;) ) thoughts on this. Thanks for the help!

Kind regards,
Ray
[QUOTE] The solution to dCa/dt = -k * Ca that you provided is only valid if k is constant, and in your case it is a function of a time varying T. [/QUOTE] Dear Nagi, thanks for your reply. I figured it had something to do with the k, but the results were both believable so it was difficult to discern what went wrong. So, you say because the function is integrated you cannot hav a varying k? So this means that the PDE solution is indeed the right one and this method the correct one, true? The PDE result does seem more logical. The flux increases since the T and therefore the k increase, but then the amount left decreases and a peak is reached. Then the T and therefore the k are constant, so the mass flux decrease is only caused by decrease of mass, which is relatively slow. This seems to be the description of the PDE's result. Let me know if there are any (small ;) ) thoughts on this. Thanks for the help! Kind regards, Ray

Nagi Elabbasi Facebook Reality Labs

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Mar 19, 2012, 10:24 a.m. EDT
Yes I would trust the PDE more in this case, but of course check it carefully! If you want to do additional checking you can also integrate the first equation analytically for the case where T is a linear function of time.

Nagi Elabbasi
Veryst Engineering
Yes I would trust the PDE more in this case, but of course check it carefully! If you want to do additional checking you can also integrate the first equation analytically for the case where T is a linear function of time. Nagi Elabbasi Veryst Engineering

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Mar 19, 2012, 11:50 a.m. EDT

Yes I would trust the PDE more in this case, but of course check it carefully! If you want to do additional checking you can also integrate the first equation analytically for the case where T is a linear function of time.

Interestingly, the time integration in COMSOL over the simulation time gave the right value (m_initial of course) for both methods. I also modeled the first set of equations in Matlab and it gave the same result as COMSOL for the flux and mass left. I wanted to model the second one in Matlab as well using ODE45 or something similar (for testing is does not need to be space dependent), but it had problems with the changing k. It only took the value for k using the first T (300K) at which rate it takes a lot of time. But anyway, it seems to be in order to use the PDE, so I am going with that then.

Also, I remembered something. I have now modeled the temperature as a function of time that I know (because I made it myself) but in my real model the temperature changes over time in an unknown (not directly described) fashion, so I can't on beforehand put the real time dependent function for k in the integral. But I see your point better now. The function for k(t) must of course be integrated as well. I'll go with the PDE.

Alright, thanks again and good luck in general,

Ray.

[QUOTE] Yes I would trust the PDE more in this case, but of course check it carefully! If you want to do additional checking you can also integrate the first equation analytically for the case where T is a linear function of time. [/QUOTE] Interestingly, the time integration in COMSOL over the simulation time gave the right value (m_initial of course) for both methods. I also modeled the first set of equations in Matlab and it gave the same result as COMSOL for the flux and mass left. I wanted to model the second one in Matlab as well using ODE45 or something similar (for testing is does not need to be space dependent), but it had problems with the changing k. It only took the value for k using the first T (300K) at which rate it takes a lot of time. But anyway, it seems to be in order to use the PDE, so I am going with that then. Also, I remembered something. I have now modeled the temperature as a function of time that I know (because I made it myself) but in my real model the temperature changes over time in an unknown (not directly described) fashion, so I can't on beforehand put the real time dependent function for k in the integral. But I see your point better now. The function for k(t) must of course be integrated as well. I'll go with the PDE. Alright, thanks again and good luck in general, Ray.

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.