October 5, 2023 at 7:14 pm
wrbulat
Ansys Employee
Hello Takabayashi,
Â
Please try the following:
Â
Â
finiÂ
/cleÂ
Â
C*******************************************************************************
C*** PARAMETERS OUTSIDE OF DO LOOP
C*******************************************************************************
height = 20*1e-6
thickness = 3*1e-6
separation = 10*1e-6
Â
width_0 = (100*1e-6) ! INITIAL (STARTING) ELECTRODE WIDTH
d_width = 1e-6 ! INCREMENTAL CHANGE IN ELECTRODE WIDTH
n_width = 5 ! NUMBER OF ELECTRODE WIDTH CASES TO INVESTIGATE
Â
*dim,C_results,,n_width,4 ! ARRAY INTO WHICH CAPACITANCE RESULTS WILL BE SAVED
Â
eps0=8.854e-12 ! FREE SPACE PERMITTIVITY
d_dmn = 10*1e-6 ! DEPTH SURROUNDING DOMAIN EXTENDS BEYOND ELECTRODES
d_inf = 5*1e-6 ! DEPTH OF INFINITE BOUNDARY ELEMENT MESHÂ
esz = 3*1e-6Â ! MESH SIZE
V = 0.01 ! APPLIED VOLTAGE
Â
Â
C*******************************************************************************
C*** DO LOOP
C*******************************************************************************
*do,i,0,n_width-1 ! LOOP OVER ELECTRODE WIDTH
Â
 pars,all ! SAVE ALL PARAMETERS TO file.parm
Â
 fini ! CLEAR MAPDL DATABBASE (THIS DELETES THE PARAMETERS, TOO!)
 /cle
Â
 parr ! RESTORE PARAMETERS FROM file.parm TO MAPDL DATABASE
Â
 width = width_0 + i*d_width ! ELECTRODE WIDTH FOR ith PASS THROUGH DO LOOP
Â
 /title,WIDTH = %width%
Â
 /vie,1,1,1,1
 /sys,del file*.png
Â
 /PREP7
Â
 C*** Configured for electrostatic analysis of 3D 8-node elements
 ET,1,SOLID123
Â
Â
 C*** Define infinite element
 ET,2,111,2,1
Â
 C*** Material properties (relative dielectric constant in vacuum)
 MP,PERX,1,1 ! RELATIVE PERMITTIVITY INSTEAD
Â
Â
 C*** Create your first plate
 BLOCK,0,width,0,height,0,-thickness
 cm,electrode1_a,area
Â
Â
 C*** Create second plate
 asel,none
 BLOCK,0,width,0,height,separation,separation+thickness
 cm,electrode2_a,area
Â
Â
 C*** SURROUNDING DOMAIN
 alls
 cm,scrap1_v,volu
 *get,xmin,kp,,mnloc,x
 *get,xmax,kp,,mxloc,x
 *get,ymin,kp,,mnloc,y
 *get,ymax,kp,,mxloc,y
 *get,zmin,kp,,mnloc,z
 *get,zmax,kp,,mxloc,z
 vsel,none
 bloc,xmin-d_dmn,xmax+d_dmn,ymin-d_dmn,ymax+d_dmn,zmin-d_dmn,zmax+d_dmn
 cm,scrap2_v,volu
 alls
 vsbv,scrap2_v,scrap1_v
Â
Â
 C*** MESH
 esiz,esz
 vmes,all
Â
Â
 C*** ELECTRODE VOLTAGE
 da,electrode1_a,volt
 da,electrode2_a,volt,V
Â
 fini
Â
Â
 C*** SOLVE
 /solu
 alls
 save
 solv
 fini
Â
Â
 C*** POST PROCESS
 /post1
 set ! READ RESULTS INTO MADL DATABASE
Â
 etab,w,sene ! BASED ON ENERGY
 ssum
 *get,Wnet,ssum,,item,w
 C1 = 2*Wnet/(V**2)
Â
 nsel,s,d,volt ! BASED ON CHARGE & VOLTAGE
 fsum
 *get,q,fsum,,item,chrg
 c2 = q/v
Â
 C_nominal=eps0*(height*width)/separation ! NOMINAL FRINGE FREE VALUE
Â
 /tla,-0.35,0.90,Capacitance (ANSYS, energy) = %C1% Fd ! ANNOTATION
 /tla,-0.35,0.85,Capacitance (ANSYS, Q/V) = %C2% Fd
 /tla,-0.35,0.80,Capacitance (nominal fringe-free) = %C_nominal% Fd
Â
 alls ! CAPPED SECTION PLOTS
 wpro,,,90
 wpof,,,width/2
 /type,1,7
 /cpl,1
Â
 plns,volt
 /sho,png $plns,volt $/sho,close $/wait,2
 plve,ef,,,,vect,,on
 /sho,png $plve,ef,,,,vect,,on $/sho,close $/wait,2
Â
 C_results(i+1,1)=width ! SAVE RESULTS IN C_results ARRAY
 C_results(i+1,2)=C_nominal
 C_results(i+1,3)=C1
 C_results(i+1,4)=C2
Â
*enddo ! END DO LOOP
Â
Â
C*********************************************************************
C*** WRITE C_results ARRAY TO results.txt TEXT FILE
C*********************************************************************
*cfopen,results,txt
*vwrite
('      Width       C_nominal    C_ANSYS (Energy) C_ANSYS (Terminal Conditions)')
*vwrite,C_results(1,1),C_results(1,2),C_results(1,3),C_results(1,4)
(4X,E16.8,4X,E16.8,4X,E16.8,4X,E16.8)
*cfclose
Â
pars,all
save
Â
/eof
Â