- Thank you received: 0
Electrostatic Examples for NGSolve Beginners
4 years 7 months ago #2590
by jleman
Replied by jleman on topic Electrostatic Examples for NGSolve Beginners
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)
- mneunteufel
- Offline
- Premium Member
Less
More
- Thank you received: 59
4 years 6 months ago #2592
by mneunteufel
Replied by mneunteufel on topic Electrostatic Examples for NGSolve Beginners
Hi jleman,
the constructor of the specialcf.normal needs the dimension. Then it can be evaluated
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)
Best
Michael
the constructor of the specialcf.normal needs the dimension. Then it can be evaluated
Code:
n = specialcf.normal(2)
value = n(mesh(*vert.point))
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
- christopher
- Offline
- Administrator
Less
More
- Thank you received: 101
4 years 6 months ago - 4 years 6 months ago #2594
by christopher
Replied by christopher on topic Electrostatic Examples for NGSolve Beginners
You can as well multiply the functions and evaluate the product:
and then evaluate Emag at boundary points:
Note that the BND flag gives you a boundary mesh point, which is needed to evaluate the normal vector.
Best
Code:
Emag = InnerProduct(E, n)
Code:
Emag_vals = Emag(mesh(*bnd_verts, BND)))
Best
Last edit: 4 years 6 months ago by christopher.
The following user(s) said Thank You: jleman
Time to create page: 0.091 seconds