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.
Differentiation
Posted 2010年10月9日 GMT-4 09:34 Version 5.2 18 Replies
Please login with a confirmed email address before reporting spam
Is it possible to differentiane an expression in variable field itself.
I have defined a variable: es.modE = (es.Ex)^2+(es.Ex)^2+(es.Ex)^2 (where es.Ex is x component of electric field etc..)
now, I need to define another variable, lets say : f_DEP = partial derivative of (es.modE) wrt x.
how can i express f_DEP in the variable field. I am using COMSOL4
plz reply asap
Please login with a confirmed email address before reporting spam
Please login with a confirmed email address before reporting spam
I also met this kind problem. What I did is exlport the data and calculate in the Matlab.
I would appreciate it if you can tell me how to do this in Comsol without matlab.
Cheers,
never mind.. was able to resolve the problem..
Please login with a confirmed email address before reporting spam
and : pd(f,x) ------ for partially differentiating the function f wrt x
you can search "mathematical operator" in help desk to know more.
in my case, i wrote: f_DEP = pd(es.modE , x)
Please login with a confirmed email address before reporting spam
I have followed your steps that defined a variables, es.modE = (es.Ex)^2+(es.Ex)^2+(es.Ex)^2 and f_DEP = pd(es.modE,x), in the local definitions of variable.
But the plot of the f_DEP is always zero at everywhere.
May you advice me what the mistakes I have possibly made?
Looking for your reply in soonest.
Thanks and regards,
Woon Huei.
Please login with a confirmed email address before reporting spam
Why not use the internal variable "es.normE", it's calculated such that it remains correct even if the E is complex, which is not the case for your "es.modE"
as es.Ex = -Vx where V is the dependent variable for the voltage, it's already derived via a derivation, hence it becomes easily somewhat "noisy" or "stepwise like"
the derivative of Ex (where (Ex,Ey,Ez) are the scalar values for the global coordinate components of the vector "E") can be expressed via the Vxx ... the second derivatives of V (provided you use at least quadratic shape functions)
--
Good luck
Ivar
Please login with a confirmed email address before reporting spam
Thanks for your reply.
From my knowledge, Derivative of electric field is equal to the sum of partial derivative of electric field respect to x, y and z directions.
I am wondering whether Vxx is the derivative of electric field respect to x or partial derivative of electric field respect to x.
If it is derivative of electric field respect to x if it is not used for analysing derivative of electric field.
Thanks and regards,
Woon Huei.
Please login with a confirmed email address before reporting spam
Vxx is the SECOND derivative of the SCALAR potential V.
Ex (the scalar x component of VECTOR E) is equal to (minus) the FIRST derivative of the scalar V along x,
Vxx is also the FIRST derivative of the scalar component Ex
in math notations
Vx = dV/dx,
Vxx = d^2V/dx^2,
Ex = -Vx, and
d(Ex)/dx = -Vxx
in vector notation E = -grad(V)
At least that is how I understand things
You can also check the underlying equations of COMSOL
--
Good luck
Ivar
Please login with a confirmed email address before reporting spam
I am having the same issue as you (plots show zero everywhere). Were you able to find a solution?
Thanks in advance,
Becky
Please login with a confirmed email address before reporting spam
Please login with a confirmed email address before reporting spam
have you checked that your discretisation is high enough to get a non zero derivatives?
Depending on which "dependent variable" you have you can only derive 2x in standard 2md order discretization, and you wil get step funtions, you need to get higher discrtisation to get smoother or higher derivatives. And several physics in the ACDC domain you work already by default on the derivative of the true solved varable field
--
Good luck
Ivar
Please login with a confirmed email address before reporting spam
I'm using Comsol 4.2 to solve the Laplace equation for a 2D geometry with 2 sets of boundary conditions. I've obtained the 2d plots for the shape of the potential in the case of the 2 sets of boundary conditions. The solutions are named by default u and u2 (I've used Laplace eq separately for the 2 sets).
Now I want to create a 2d plot surface using the 2 solutions from above. The expression that I want to use for my plot is:
log(grad(|grad(u)|^2+|grad(u2)|^2))
if I use only the expression |grad(u)|^2+|grad(u2)|^2=abs(uxx+uyy)^2+abs(u2xx+u2yy)^2 the plot gives me a nonzero value. But if I try to differentiate the expression |grad(u)|^2+|grad(u2)|^2 the plot gives me zero everywhere.
I've tried to use the operators d(f,x) and pd(f,x) in the definition of my expression but the result is always zero.
Could someone help me please!
thanks
Ciprian
Please login with a confirmed email address before reporting spam
I do not really follow you, for me uxx is the second derivative of the dependent variable u, but grad(u) should be based on the first derivative, no ?
And probably the d() operator has an issue with the abs() function that is not derivable for an argument aroud "0"
--
Good luck
Ivar
Please login with a confirmed email address before reporting spam
In the end I've figured out, after many trials, what was the problem.
Now my plots are not empty anymore :)
Ivar you are wright..one problem was that I've used uxx instead of ux for the definition of grad(u)..I've noticed that almost immediately after posting my comment on the forum. and the other problem was with the correct definition of the function
Ciprian
Please login with a confirmed email address before reporting spam
Hi Ciprian,
How did you solve the problem with zero partial differentiating of the electric field. I have the same problem. I am using pd(es.Ez,z) or pd(es.normE,z) . Neither of them gives me nonzero plot. Besides, I would like to define a parameter as Ezz, for instance and export it in MATLAB via matlab livelink. I would appreciate if you could help me out.
Thanks,
Elham
Hi
In the end I've figured out, after many trials, what was the problem.
Now my plots are not empty anymore :)
Ivar you are wright..one problem was that I've used uxx instead of ux for the definition of grad(u)..I've noticed that almost immediately after posting my comment on the forum. and the other problem was with the correct definition of the function
Ciprian
Please login with a confirmed email address before reporting spam
I've used the function d(expresion,x)...in your case it would be d(ec.Ez,z)..but probably this is not why your plots are empty.
I don't know what problem are you trying to solve..but in my case I was solving the Laplace equation..and the unknown (i.e the potential)it was given the implicit name u by Comsol. Then I've used that variable for my plots. one of the plot was of the form:
log10(sqrt(ux^2+uy^2)) and I've got a nonzero plot.
I recommend you to build you expressions for the plots using the implicit names given to your variables by Comsol.
You could also have zero plots because your boundary condition for the problem are not the right ones..you should also check that.
Regarding haw to export an expresion in Matlab form Comsol I'm afraid that I can't help you..I've never used that function of comsol so far.
Ciprian
Please login with a confirmed email address before reporting spam
--
Alessia Polemi
Please login with a confirmed email address before reporting spam
I am also facing the same problem. I need to evaluate d(log(p/patm),rho) but it is returning zero value. rho is a dependent variable which I am specifying through a user defined general pde.
Any suggestions?
Thanks
Mahvash
Please login with a confirmed email address before reporting spam
See www.comsol.com/blogs/plotting-spatial-derivatives-magnetic-field/ for a way to get the plot you are after by mapping the solution onto a higher order mesh.
Best,
Jeff
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.