Plotting the Electric Field of a 3D Parallel Plate

조회 수: 31 (최근 30일)
Hayden Bland
Hayden Bland 2020년 10월 2일
답변: Star Strider 2020년 10월 2일
The code below creates a parallel plate capacitor with a 1000V potential on the top plate, 0V potential on the bottom, and no flow through the wall. Using the PDE solver I've managed to get the nodal solution of the model which represents the electric potential. I wish to know how to properly take and plot the gradient of the field as to produce the electric field at each node. Below is what I have thus far:
model = createpde(3);
importGeometry(model,'Parallel Plate Capacitor.SLDPRT.STL')
figure(1)
pdegplot(model,'FaceLabels','on','FaceAlpha',0.2) % creates simple 3D model
axis equal
applyBoundaryCondition(model,'mixed','Face',[1,2,3],...
'u',[0,0],'EquationIndex',[1,2],...
'q',[0;0;0],'g',[0;0;0]); % try with no BC
applyBoundaryCondition(model,'dirichlet','Face',3,'u',[1000;1000;1000]) % BC for top plate
applyBoundaryCondition(model,'dirichlet','Face',2,'u',[0;0;0]) % BC for bottom plate
generateMesh(model)
pdeplot3D(model)
f = [0;0;0]; % source charge (constant)
CA = specifyCoefficients(model,'m',0,...
'd',0,...
'c',1,...
'a',0,...
'f', f);
results = solvepde(model);
v = results.NodalSolution;
pdeplot3D(model,'ColorMapData',v(:,3), 'FaceAlpha', 0.5)
vectorField = gradient(v);
Taking the gradient of the nodalSolutions gives me (hopefully) electric field values in the x,y, and z components of each node. I want to know how I can plot these values onto 3D plot to show the direction and flow of the electric field.
Thank you.

채택된 답변

Star Strider
Star Strider 2020년 10월 2일
To get the gradient over multiple dimensions, get multiple outputs from it. See specifically Contour Plot of Vector Field for a 2D example. A 3D version would require quiver3. (I don’t have the geometry, so I can’t run your code.)

추가 답변 (0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by