Robert Koslover
Certified Consultant
Please login with a confirmed email address before reporting spam
Posted:
8 years ago
05.03.2017, 15:15 GMT-5
I'm not surprised that you can't specify a recursive assignment statement in the form of directly defining a variable in Comsol, but I'm curious about what other users may have to offer about other ways of accomplishing it. That said, I'm even more curious about *why* you want to do this. Would you care to share/explain your overall objective with the rest of us at this forum?
Thanks.
I'm not surprised that you can't specify a recursive assignment statement in the form of directly defining a variable in Comsol, but I'm curious about what other users may have to offer about other ways of accomplishing it. That said, I'm even more curious about *why* you want to do this. Would you care to share/explain your overall objective with the rest of us at this forum?
Thanks.
Please login with a confirmed email address before reporting spam
Posted:
8 years ago
05.03.2017, 15:23 GMT-5
I'm not surprised that you can't specify a recursive assignment statement in the form of directly defining a variable in Comsol, but I'm curious about what other users may have to offer about other ways of accomplishing it. That said, I'm even more curious about *why* you want to do this. Would you care to share/explain your overall objective with the rest of us at this forum?
Thanks.
This is a biofilm model which consumes cellulose and produce H2. pH value would greatly affect the performance. The equation given above is used to calculate the pH. I built the model firstly on matlab. Matlab could solve this non linear equation by using fsolve. I am wondering how could I implement this in COMSOL.
[QUOTE]
I'm not surprised that you can't specify a recursive assignment statement in the form of directly defining a variable in Comsol, but I'm curious about what other users may have to offer about other ways of accomplishing it. That said, I'm even more curious about *why* you want to do this. Would you care to share/explain your overall objective with the rest of us at this forum?
Thanks.
[/QUOTE]
This is a biofilm model which consumes cellulose and produce H2. pH value would greatly affect the performance. The equation given above is used to calculate the pH. I built the model firstly on matlab. Matlab could solve this non linear equation by using fsolve. I am wondering how could I implement this in COMSOL.
Henrik Sönnerlind
COMSOL Employee
Please login with a confirmed email address before reporting spam
Posted:
8 years ago
06.03.2017, 01:30 GMT-5
Hi,
There are several ways to deal with such situations. The one which seems to be closest too your case is described in this blog post :
www.comsol.com/blogs/solving-algebraic-field-equations/
There are also a number of forum threads in which problems of circular dependencies are discussed, for example
www.comsol.com/community/forums/general/thread/48995
Regards,
Henrik
Hi,
There are several ways to deal with such situations. The one which seems to be closest too your case is described in this blog post : https://www.comsol.com/blogs/solving-algebraic-field-equations/
There are also a number of forum threads in which problems of circular dependencies are discussed, for example https://www.comsol.com/community/forums/general/thread/48995
Regards,
Henrik
Please login with a confirmed email address before reporting spam
Posted:
8 years ago
06.03.2017, 02:43 GMT-5
Hello,
I would suggest that you add a general form PDE Interface to
your model. Then set all coefficients to zero except of f.
f is specified like this:
f = A - a/(A+b)-c/(A+d)-e/(A+f)+g/(1+h/A)
so you need to solve this nonlinear implicit algebraic equation with
respect to the variable A.
As an initial value you can set zero, 2 or maybe an equation from an
analytical solution.
One year ago I also tried to solve this kind of equation with MATLAB and
fsolve. I didn't work that well. COMSOL is far better in that regard.
Hello,
I would suggest that you add a general form PDE Interface to
your model. Then set all coefficients to zero except of f.
f is specified like this:
f = A - a/(A+b)-c/(A+d)-e/(A+f)+g/(1+h/A)
so you need to solve this nonlinear implicit algebraic equation with
respect to the variable A.
As an initial value you can set zero, 2 or maybe an equation from an
analytical solution.
One year ago I also tried to solve this kind of equation with MATLAB and
fsolve. I didn't work that well. COMSOL is far better in that regard.
Please login with a confirmed email address before reporting spam
Posted:
8 years ago
06.03.2017, 18:20 GMT-5
Thank you so much for your links. They help a lot!
Kind regards,
Weiyi
Thank you so much for your links. They help a lot!
Kind regards,
Weiyi
Please login with a confirmed email address before reporting spam
Posted:
8 years ago
06.03.2017, 18:21 GMT-5
Hello,
I would suggest that you add a general form PDE Interface to
your model. Then set all coefficients to zero except of f.
f is specified like this:
f = A - a/(A+b)-c/(A+d)-e/(A+f)+g/(1+h/A)
so you need to solve this nonlinear implicit algebraic equation with
respect to the variable A.
As an initial value you can set zero, 2 or maybe an equation from an
analytical solution.
One year ago I also tried to solve this kind of equation with MATLAB and
fsolve. I didn't work that well. COMSOL is far better in that regard.
I tried your method and I think it actually works!
Thank you very much.
Kind regards,
Weiyi
[QUOTE]
Hello,
I would suggest that you add a general form PDE Interface to
your model. Then set all coefficients to zero except of f.
f is specified like this:
f = A - a/(A+b)-c/(A+d)-e/(A+f)+g/(1+h/A)
so you need to solve this nonlinear implicit algebraic equation with
respect to the variable A.
As an initial value you can set zero, 2 or maybe an equation from an
analytical solution.
One year ago I also tried to solve this kind of equation with MATLAB and
fsolve. I didn't work that well. COMSOL is far better in that regard.
[/QUOTE]
I tried your method and I think it actually works!
Thank you very much.
Kind regards,
Weiyi