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
Â