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.

calculation of derivative in 3D

Please login with a confirmed email address before reporting spam

Hi all,
I want to run a calculation in comsol, and for that, I need to calculate the derivative of a function
I already ran this calculation in 2D and it works, but while I get to 3D, the derivative is calculated as zero although it is not:
To check that I went to:
Postprocessing -> cross section Plot Parameters
In line/extrusion tab, I choose magnetic flux density, x component, I have a graph that its derivative cannot be zero (attached)
Then I type d(Bx_emqa,x) in expression case, the graph of the result is zero(attached)!
What am I doing wrong? the syntax of derivative in 3D is different than the one in 2D?
thanks


10 Replies Last Post 04.07.2012, 04:27 GMT-4
COMSOL Moderator

Hello Rana Afshar

Your Discussion has gone 30 days without a reply. If you still need help with COMSOL and have an on-subscription license, please visit our Support Center for help.

If you do not hold an on-subscription license, you may find an answer in another Discussion or in the Knowledge Base.


Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 16.07.2011, 12:59 GMT-4
Hey

how are you?

did you solve described problem?
becuse i have exactly the same problem

Thanks a lot and
Best regards,
Arye Nudelman
Hey how are you? did you solve described problem? becuse i have exactly the same problem Thanks a lot and Best regards, Arye Nudelman

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 02.08.2011, 14:53 GMT-4
I also have exactly the same problem.
I also have exactly the same problem.

Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 14.08.2011, 11:33 GMT-4
Hi

I do not have access to my COMSOL running PC, but there are a few things to know abot derivatives: COMSOl can only extract them if the shape functions are of high enough order (2 or more). Then COMSOl has already defined as variables most of the first and second order derivatives. Do not forget that for ACDC you solve for A, the B is then derived from the derivative of A and the gradient of B from the second derivative of A. So if you are looking for the first derivative of the gradient, your are using the third derivative of the dependet variable A, hence you need at least 3rd order shape functions.

I suspect this is the reason why you get only "0". the > 2nd derivative of a second ordr equation is "0" so mathemataically it is correct ;)

Even if COMSOl is looking after most of the physics and math behind the scene, you must be sure you understand too, the FEM limitations underneath

--
Good luck
Ivar
Hi I do not have access to my COMSOL running PC, but there are a few things to know abot derivatives: COMSOl can only extract them if the shape functions are of high enough order (2 or more). Then COMSOl has already defined as variables most of the first and second order derivatives. Do not forget that for ACDC you solve for A, the B is then derived from the derivative of A and the gradient of B from the second derivative of A. So if you are looking for the first derivative of the gradient, your are using the third derivative of the dependet variable A, hence you need at least 3rd order shape functions. I suspect this is the reason why you get only "0". the > 2nd derivative of a second ordr equation is "0" so mathemataically it is correct ;) Even if COMSOl is looking after most of the physics and math behind the scene, you must be sure you understand too, the FEM limitations underneath -- Good luck Ivar

Hendrik Santoso Sugiarto

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 25.08.2011, 04:10 GMT-4
I also encountered the same problem
I have tried different cross section line and ended up with zero result when I differentiated it
anyone knows the solution?
I also encountered the same problem I have tried different cross section line and ended up with zero result when I differentiated it anyone knows the solution?

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 22.09.2011, 18:23 GMT-4
I'm afraid I have the same question. I'm not able to derive dB/dz from A. It says it cannot be evaluation as shown in the picture attached. I think it should be Axyz but it does not work.
I'm afraid I have the same question. I'm not able to derive dB/dz from A. It says it cannot be evaluation as shown in the picture attached. I think it should be Axyz but it does not work.


Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 21.01.2012, 12:49 GMT-5
Hi, i try to get the derivative of H in x,y,z direction in MF module(3D) by using the command d(Hx,x). while the result is zero. i already changed the discretization option to cubic. can you help me out. thanks
Hi, i try to get the derivative of H in x,y,z direction in MF module(3D) by using the command d(Hx,x). while the result is zero. i already changed the discretization option to cubic. can you help me out. thanks

Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 22.01.2012, 09:07 GMT-5
Hi

indeed in my up to date 4.2a in 2D I can plot the derivative d(mf.Hx,x) even with default second order discretisation, but in 3D it's all = 0 even if I select higher order discretisation.

Not sure why, it seems that B is calculated slightly differently internally between 2D and 3D, could it be from the way the Bx = curl of Ax is extracted ?

It's worth to try to ask support if nobody else has a good reply that we have missed ;)

--
Good luck
Ivar
Hi indeed in my up to date 4.2a in 2D I can plot the derivative d(mf.Hx,x) even with default second order discretisation, but in 3D it's all = 0 even if I select higher order discretisation. Not sure why, it seems that B is calculated slightly differently internally between 2D and 3D, could it be from the way the Bx = curl of Ax is extracted ? It's worth to try to ask support if nobody else has a good reply that we have missed ;) -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 09.06.2012, 09:29 GMT-4
Hi,

this is exactly also my problem.


Has anybody found a solution to this yet ?


(I'am also going to need the surface tangential derivative of B but that should be the same issue)

There is also another unanswered thread dealing with this...www.comsol.com/community/forums/general/thread/24993/


thank you

\Flanell

Hi, this is exactly also my problem. Has anybody found a solution to this yet ? (I'am also going to need the surface tangential derivative of B but that should be the same issue) There is also another unanswered thread dealing with this...http://www.comsol.com/community/forums/general/thread/24993/ thank you \Flanell

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 12.06.2012, 16:58 GMT-4
Hi


I have asked the support. Here's the answer:

---
The cause of the issue is that 3D electromagnetic models in COMSOL are
solved using vector (curl) elements. In contrast to Lagrange elements used
for other physics interfaces, second derivatives are not at all defined on
vector elements. This is the reason that spatial gradients of B, H and J -
which are all related to the first derivative of the magnetic vector
potential A being the independent (solution) variable - cannot be
visualized directly within the AC/DC Module.
---

There's a really simple solution to it:
You just have to map the variable you want to derive onto another one defined on Lagrange elements.
You even get a bonus: polynomial patch recovery for smoother plots is available then.

Details attached.


It worked for me right away. Thank you support. I wonder why this is not in KB.


--
______
Flanell
Hi I have asked the support. Here's the answer: --- The cause of the issue is that 3D electromagnetic models in COMSOL are solved using vector (curl) elements. In contrast to Lagrange elements used for other physics interfaces, second derivatives are not at all defined on vector elements. This is the reason that spatial gradients of B, H and J - which are all related to the first derivative of the magnetic vector potential A being the independent (solution) variable - cannot be visualized directly within the AC/DC Module. --- There's a really simple solution to it: You just have to map the variable you want to derive onto another one defined on Lagrange elements. You even get a bonus: polynomial patch recovery for smoother plots is available then. Details attached. It worked for me right away. Thank you support. I wonder why this is not in KB. -- ______ Flanell


Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 04.07.2012, 04:27 GMT-4
Hey,

Thank you so much for this pdf, it helped me a lot further. But I have an other problem now. From the solution i created a selection, and now, when i want to export the data for only this selection, the exported values give: NaN instead. I did not change anything except that i changed the solution to only a selection of the solution. Any help?
Hey, Thank you so much for this pdf, it helped me a lot further. But I have an other problem now. From the solution i created a selection, and now, when i want to export the data for only this selection, the exported values give: NaN instead. I did not change anything except that i changed the solution to only a selection of the solution. Any help?

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.