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.

how to write an user defined PDE?

Please login with a confirmed email address before reporting spam

Dear all

I am trying to write a PDE as attached. I have tried with the "coefficient form of PDE" physics, but, I am unable to write down the first term in right hand side of the equation (see attached file). Can anyone help me to complete the equation using "coefficient form of PDE" physics?



Thanking you in advance

Anup


15 Replies Last Post 28 août 2014, 07:41 UTC−4

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 25 août 2014, 11:17 UTC−4
I solved an equation like this before. I used General form that time.

simply use utx as the term in flux in general form.
I solved an equation like this before. I used General form that time. simply use utx as the term in flux in general form.

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 25 août 2014, 12:03 UTC−4
To be honest, I am not sure which method is best for the solution time and proneness to errors. Maybe someone else can add to this. I myselve have had problems with dumping derivatives that I can not place in the force term field (1st method) and prefer to use the weak formulation.


1) You can express that term with partial derivatives. You can write derivatives in Comsol as shown in the previous post or by using the d(,) function.

After making your expression you can put it in the force term or if convenient, or more logical, somewhere else.

2) You might turn this single equation into two coupled equations by defining a second variable as the derivative of u. This definition is your second equation and the second variable can be filled into you original equation such that you can easily use the coefficient form. The advantage would be that you don't hack or abuse the coefficient form module be putting derivatives into it and changing the meaning of the coefficients.

To be honest, I am not sure which method is best for the solution time and proneness to errors. Maybe someone else can add to this. I myselve have had problems with dumping derivatives that I can not place in the force term field (1st method) and prefer to use the weak formulation. 1) You can express that term with partial derivatives. You can write derivatives in Comsol as shown in the previous post or by using the d(,) function. After making your expression you can put it in the force term or if convenient, or more logical, somewhere else. 2) You might turn this single equation into two coupled equations by defining a second variable as the derivative of u. This definition is your second equation and the second variable can be filled into you original equation such that you can easily use the coefficient form. The advantage would be that you don't hack or abuse the coefficient form module be putting derivatives into it and changing the meaning of the coefficients.

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 25 août 2014, 12:14 UTC−4
I was wrong with that second method. Just use terms like utx, and others if you have multiple dimensions.
I was wrong with that second method. Just use terms like utx, and others if you have multiple dimensions.

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 25 août 2014, 13:40 UTC−4
Dear Martijn

Thanks for your suggestion. But, I am sorry I could not understand 'utx'. The variable 'u' is a function of three space coordinates and time. How to incorporate (grad)^2 in "coefficient form of PDE" physics?


regards

Anup
Dear Martijn Thanks for your suggestion. But, I am sorry I could not understand 'utx'. The variable 'u' is a function of three space coordinates and time. How to incorporate (grad)^2 in "coefficient form of PDE" physics? regards Anup

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 25 août 2014, 14:26 UTC−4
Dear Hossein

Thanks for the reply. That's fine if I use utx, uty and utz in conservative flux in "general form PDE- physics". But then, I have two issues:

(A) The first term in the RHS of my equation (see attachment) also contain a coefficient 'X4'. How to incorporate that?

(B) If I write utx, uty, utz; that represents derivative of u with respect to (t,x), (t,y), (t,z) respectively. But, the third term in the LHS of my equation contains second order derivative of u with respect to (x, y, z ) not a derivative of 't'. How to take care that? Moreover, the third term in the LHS of my equation also contains a coefficient 'X3'.


Thanks in advance

Anup
Dear Hossein Thanks for the reply. That's fine if I use utx, uty and utz in conservative flux in "general form PDE- physics". But then, I have two issues: (A) The first term in the RHS of my equation (see attachment) also contain a coefficient 'X4'. How to incorporate that? (B) If I write utx, uty, utz; that represents derivative of u with respect to (t,x), (t,y), (t,z) respectively. But, the third term in the LHS of my equation contains second order derivative of u with respect to (x, y, z ) not a derivative of 't'. How to take care that? Moreover, the third term in the LHS of my equation also contains a coefficient 'X3'. Thanks in advance Anup


Please login with a confirmed email address before reporting spam

Posted: 10 years ago 25 août 2014, 14:44 UTC−4
Anup

1) I though X values are constant and are not depending on x,y,z. If X values are also scalar fields, then you need to expand you equations and put the remaining terms as f. But if X4 is constant then just put is with the other term in flux .

2) second derivatives of space also will go to the flux term (as ux, uy , uz ,....). so add these term to the previous terms in the flux.

You need to play with the terms a little bit, but finally put the remaining terms as f.
Anup 1) I though X values are constant and are not depending on x,y,z. If X values are also scalar fields, then you need to expand you equations and put the remaining terms as f. But if X4 is constant then just put is with the other term in flux . 2) second derivatives of space also will go to the flux term (as ux, uy , uz ,....). so add these term to the previous terms in the flux. You need to play with the terms a little bit, but finally put the remaining terms as f.

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 25 août 2014, 14:48 UTC−4
Dear Hossein

I got it, how to incorporate the coefficient 'X4'.

Please help me for second question.

Thank you in advance


Anup
Dear Hossein I got it, how to incorporate the coefficient 'X4'. Please help me for second question. Thank you in advance Anup

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 25 août 2014, 17:24 UTC−4
So again that term will also go in the flux and add to the previous term from the RHS.

You need to add ux in the first flux, uy is the second and so forth. Gamma sign mean derivative, it will apply to the ux and make a uxx.

Best,
Hossein
So again that term will also go in the flux and add to the previous term from the RHS. You need to add ux in the first flux, uy is the second and so forth. Gamma sign mean derivative, it will apply to the ux and make a uxx. Best, Hossein

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 26 août 2014, 05:33 UTC−4
Doesn't your coefficient X_3 correspond to the diffusion coefficient in the coefficient form PDE?
Doesn't your coefficient X_3 correspond to the diffusion coefficient in the coefficient form PDE?

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 26 août 2014, 08:38 UTC−4
Dear Hossein

Thanks once again. What I have understood from your reply is attached with this message. Please see the attachment and reply me if my understanding is correct.


Thank you in advance


Anup
Dear Hossein Thanks once again. What I have understood from your reply is attached with this message. Please see the attachment and reply me if my understanding is correct. Thank you in advance Anup


Please login with a confirmed email address before reporting spam

Posted: 10 years ago 26 août 2014, 08:45 UTC−4
yes....X3 is the diffusion coefficient........


But....I have observed..... using "coefficient form PDE" in my problem will be a difficult one...and hence now I am trying "General form PDE"



regards

Anup
yes....X3 is the diffusion coefficient........ But....I have observed..... using "coefficient form PDE" in my problem will be a difficult one...and hence now I am trying "General form PDE" regards Anup

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 26 août 2014, 10:18 UTC−4
Anup

It seems like you got the points. Except I think you forgot the X3 and X4 in the last two equations, but then they are constants and you can include them in any field.

Also for utx or uxt you can write: d(d(u,x),t)

Good luck,
Hossein
Anup It seems like you got the points. Except I think you forgot the X3 and X4 in the last two equations, but then they are constants and you can include them in any field. Also for utx or uxt you can write: d(d(u,x),t) Good luck, Hossein

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 26 août 2014, 10:27 UTC−4
If X3 is a constant it can be taken outside of the derivative and you get the laplacian uxx + uyy + uzz.
If X3 is a variable then you get X3 (uxx + uyy + uzz) + (X3x ux +X3y uy +X3z uz).

I recommend you try to study this mathematics because simply taking over the formulas will get you a model that you don't understand.

Note that the divergence is a vector operator. Div u, with u a scalar, results in a vector {ux,uy,uz}. div div u is the dot product of two vectors and results again in a scalar {dx,dy,dz}*{ux,uy,uz} = (uxx+uyy+uzz}. With div ( c div u) you get also a dot product {dx,dy,dz}{c ux, c uy, c uz} = dx (c ux) + dy (c uy) + dz (c uz).
If X3 is a constant it can be taken outside of the derivative and you get the laplacian uxx + uyy + uzz. If X3 is a variable then you get X3 (uxx + uyy + uzz) + (X3x ux +X3y uy +X3z uz). I recommend you try to study this mathematics because simply taking over the formulas will get you a model that you don't understand. Note that the divergence is a vector operator. Div u, with u a scalar, results in a vector {ux,uy,uz}. div div u is the dot product of two vectors and results again in a scalar {dx,dy,dz}*{ux,uy,uz} = (uxx+uyy+uzz}. With div ( c div u) you get also a dot product {dx,dy,dz}{c ux, c uy, c uz} = dx (c ux) + dy (c uy) + dz (c uz).

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 28 août 2014, 07:40 UTC−4
Thank you very much Hossein........



with regards

Anup
Thank you very much Hossein........ with regards Anup

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 28 août 2014, 07:41 UTC−4
Thank you very much Martijn for the suggestion....



with regards

Anup
Thank you very much Martijn for the suggestion.... with regards Anup

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.