Forum Message

 

 

We have moved the forum to https://forum.ngsolve.org . This is an archived version of the topics until 05/05/23. All the topics were moved to the new forum and conversations can be continued there. This forum is just kept as legacy to not invalidate old links. If you want to continue a conversation just look for the topic in the new forum.

Notice

The forum is in read only mode.

Electrostatic Examples for NGSolve Beginners

More
3 years 11 months ago #2590 by jleman
Gauss's law applied at the surface can be used to calculate surface charge density. The resulting equation is the dot product of the Electric field vector and surface normal vector at the surface of interest. How would I correct the following code to implement that at the "top" surface defined in bnd_verts?
Code:
Emag = set() #electric field magnitude array for vert in bnd_verts: #bnd_verts contains the mesh vertices of the "top" boundary (see above reply) n = specialcf.normal(mesh(*vert.point)) #surface normal at each of the vertices in "top"? Emag.add(InnerProduct(n,E(mesh(*vert.point)))) #dot product between normal,n and electric field, E? print(Emag)
More
3 years 11 months ago #2592 by mneunteufel
Hi jleman,

the constructor of the specialcf.normal needs the dimension. Then it can be evaluated
Code:
n = specialcf.normal(2) value = n(mesh(*vert.point))
However, on the corner the normal vector may direct into the wrong direction (e.g. to the right instead to the top on the top right corner). It is better to directly use n=(0,1)
Code:
n = (0,1) for vert in bnd_verts: E_p =E(mesh(*vert.point)) Emag.add(n[0]*E_p[0]+n[1]*E_p[1])

Best
Michael
The following user(s) said Thank You: jleman
More
3 years 11 months ago - 3 years 11 months ago #2594 by christopher
You can as well multiply the functions and evaluate the product:
Code:
Emag = InnerProduct(E, n)
and then evaluate Emag at boundary points:
Code:
Emag_vals = Emag(mesh(*bnd_verts, BND)))
Note that the BND flag gives you a boundary mesh point, which is needed to evaluate the normal vector.
Best
Last edit: 3 years 11 months ago by christopher.
The following user(s) said Thank You: jleman
Time to create page: 0.180 seconds