main.cpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. // This code simulates the static deflection and small-signal vibration of a collapsed 3D CMUT while supposing axisymmetry.
  2. // A CMUT is a microscale ultrasonic transducer with an electrostatic actuation. In collapse mode the CMUT membrane is
  3. // pulled-in, i.e. touches the bottom of the cavity.
  4. //
  5. // The CMUT geometry and mesh in this example are created using sparselizard.
  6. // The CMUT is made up of (from bottom layer to top):
  7. //
  8. // - a substrate (not in this example)
  9. // - a ground electrode
  10. // - an insulator layer (SiO2)
  11. // - a vacuum cavity
  12. // - a membrane layer (Silicon)
  13. // - an electrode
  14. #include "sparselizardbase.h"
  15. using namespace mathop;
  16. // Arguments are:
  17. //
  18. // CMUT radius, thickness of the membrane, depth of the cavity, insulator thickness and x-length of the pillar supporting the membrane.
  19. //
  20. mesh createmesh(double r, double thmem, double thcav, double thins, double lpillar);
  21. void sparselizard(void)
  22. {
  23. // Define the CMUT geometric dimensions [m]:
  24. double r = 20e-6, thmem = 0.5e-6, thcav = 0.5e-6, thins = 0.3e-6, lpillar = 10e-6;
  25. // Axisymmetric assumption:
  26. setaxisymmetry();
  27. // The domain regions as defined in 'createmesh':
  28. int membrane = 1, pillar = 2, cavity = 3, ground = 4, electrode = 5, insulator = 6;
  29. // Create the geometry and the mesh:
  30. mesh mymesh = createmesh(r, thmem, thcav, thins, lpillar);
  31. // Write the mesh for display:
  32. mymesh.write("cmutaxisym.msh");
  33. // Define additional regions:
  34. int contact = regionintersection({membrane, cavity});
  35. int solid = regionunion({membrane, pillar, insulator});
  36. int wholedomain = regionunion({solid,cavity});
  37. // Nodal shape functions 'h1' for v (the electric potential) and
  38. // u (membrane displacement). Three components are used for u.
  39. // Field umesh is used to smoothly deform the mesh in the cavity.
  40. //
  41. field u("h1xyz"), v("h1"), umesh("h1xyz"), nodalforcebalance("h1xyz");
  42. // Clamp the insulator:
  43. u.setconstraint(insulator);
  44. v.setconstraint(electrode, 120);
  45. v.setconstraint(ground, 0);
  46. // Set a conditional constraint on compy(u), the y component of the mechanical deflection.
  47. // The constraint is active for all nodal degrees of freedom at which 'contactcondition' is positive or zero.
  48. //
  49. // There is mechanical contact if either the deflection is larger than a given threshold
  50. // (chosen as 99% of the gap size times 1+1e-6, not 100% to avoid the need of remeshing the cavity)
  51. // or if at the same time:
  52. //
  53. // - compy(u) is greater than a given deflection (99% of the gap size)
  54. // - the y direction force balance on the node is negative, i.e. the node is pulled downwards
  55. //
  56. expression contactcondition = orpositive({-compy(u)-(thcav+1e-6*thcav)*0.99, andpositive({-compy(u)-thcav*0.99, -compy(nodalforcebalance)})});
  57. // Set the conditional constraint on the y component of the deflection field u:
  58. u.compy().setconditionalconstraint(contact, contactcondition, -0.99*(thcav+1e-8*thcav));
  59. // Young's modulus [Pa], Poisson's ratio [], the density [kg/m^3] and the electric permittivity [F/m]:
  60. parameter E, nu, rho, epsilon;
  61. E|solid = 150e9; E|insulator = 66e9;
  62. nu|solid = 0.25; nu|insulator = 0.17;
  63. rho|solid = 2320; rho|insulator = 2200;
  64. epsilon|cavity = 8.854e-12;
  65. epsilon|solid = 11.7*8.854e-12;
  66. epsilon|insulator = 3.9*8.854e-12;
  67. // An electrostatic formulation is used for the electric problem.
  68. // An elasticity formulation is used for the mechanical problem.
  69. // Geometrical nonlinearity is taken into account.
  70. // A forcebalance formulation is used for the conditional constraint.
  71. formulation electrostatics, elasticity, forcebalance;
  72. // Weak electrostatic formulation, computed on the mesh deformed by field umesh:
  73. electrostatics += integral(wholedomain, umesh, epsilon*grad(dof(v))*grad(tf(v)));
  74. // Weak elasticity formulation with geometrical nonlinearity
  75. // (refer to the documentation to add prestress with the last argument).
  76. elasticity += integral(solid, predefinedelasticity(dof(u), tf(u), u, E, nu, 0.0));
  77. // Electrostatic forces, computed on the elements of the whole electric domain
  78. // but with mechanical deflection test functions tf(u) only on solid.
  79. //
  80. // The electrostatic forces often appear in MEMS simulations and are thus predefined.
  81. // The inputs are the gradient of the test function of u defined on the mechanical domain,
  82. // the gradient of the previously computed electric potential field and the electric permittivity.
  83. //
  84. // The electrostatic forces are computed on the mesh deformed by field umesh.
  85. elasticity += integral(wholedomain, umesh, predefinedelectrostaticforce(tf(u,solid), grad(v), epsilon));
  86. // Formulation (based on the elasticity) to get the force balance on the contact region:
  87. forcebalance += integral(solid, -predefinedelasticity(u, tf(nodalforcebalance,contact), u, E, nu, 0.0));
  88. forcebalance += integral(wholedomain, umesh, -predefinedelectrostaticforce(tf(nodalforcebalance,contact), grad(v), epsilon));
  89. // Solve the Laplace equation in the cavity to smoothly deform the mesh.
  90. // umesh is forced to field u on region solid:
  91. umesh.setconstraint(solid, u);
  92. formulation laplacian;
  93. laplacian += integral(wholedomain, grad(dof(compx(umesh)))*grad(tf(compx(umesh))) + grad(dof(compy(umesh)))*grad(tf(compy(umesh))) + grad(dof(compz(umesh)))*grad(tf(compz(umesh))));
  94. // NONLINEAR ITERATION TO GET THE STATIC DEFLECTION:
  95. // Start with an all-zero solution vector for the elasticity formulation:
  96. vec solu(elasticity);
  97. double relresnorm = 1; int iter = 0;
  98. while (relresnorm > 1e-8)
  99. {
  100. electrostatics.generate();
  101. vec solv = solve(electrostatics.A(), electrostatics.b());
  102. // Transfer the data from the solution vector to the v field:
  103. v.setdata(wholedomain, solv);
  104. // Write the electric field computed and saved on the geometry deformed by umesh.
  105. (-grad(v)).write(wholedomain, umesh, "E.pos");
  106. v.write(wholedomain, umesh, "v.pos");
  107. // Calculate the force balance at the contact using the now known electric potential:
  108. forcebalance.generate();
  109. // The force balance is in the right handside vector:
  110. nodalforcebalance.setdata(contact, forcebalance.b());
  111. // Compute the membrane deflection:
  112. elasticity.generate();
  113. // Get the vector b and matrix A of problem Ax = b. Here they include the conditional constraints:
  114. vec b = elasticity.b();
  115. mat A = elasticity.A();
  116. // Compute the norm of the relative residual to check the convergence:
  117. relresnorm = (b-A*solu).norm()/b.norm();
  118. solu = solve(A,b);
  119. u.setdata(solid, solu);
  120. // Write the deflection u:
  121. u.write(solid, "u.pos");
  122. // Smooth the mesh in the cavity:
  123. laplacian.generate();
  124. vec solumesh = solve(laplacian.A(), laplacian.b());
  125. // Save the smoothed mesh in the cavity:
  126. umesh.setdata(wholedomain, solumesh);
  127. // Print the iteration number and relative residual norm:
  128. std::cout << "Rel. res. norm @it " << iter << " is " << relresnorm << ", max deflection is " << abs(compy(u)).max(contact, 5)[0]*1e9 << " nm" << std::endl;
  129. iter++;
  130. }
  131. // HARMONIC PERTURBATION AROUND THE STATIC DEFLECTION:
  132. // AC electric actuation frequency:
  133. setfundamentalfrequency(1e6);
  134. // Fields uh and vh have a constant deflection plus a harmonic deflection (harmonics 1 and 2):
  135. // uh = uh1 + uh2 * sin(2*pi*f0*t), vh = vh1 + vh2 * sin(2*pi*f0*t)
  136. field uh("h1xyz", {1,2}), vh("h1", {1,2});
  137. // Set the static deflection to the above solution:
  138. uh.harmonic(1).setdata(solid, solu|u);
  139. // Clamp the insulator:
  140. uh.setconstraint(insulator);
  141. // Set the same conditional constraint as above:
  142. uh.harmonic(1).compy().setconditionalconstraint(contact, contactcondition, -0.99*(thcav+1e-8*thcav));
  143. // The vibration around the static deflection is 0 at the contact:
  144. uh.harmonic(2).setconditionalconstraint(contact, contactcondition, array3x1(0,0,0));
  145. // Set the DC voltage bias on the electrode:
  146. vh.harmonic(1).setconstraint(electrode, 120);
  147. // Set a tiny AC voltage on vh2:
  148. vh.harmonic(2).setconstraint(electrode, 1);
  149. // Ground:
  150. vh.setconstraint(ground);
  151. // Redefine the electrostatic and elasticity formulations as above:
  152. formulation helectrostatics, helasticity;
  153. helectrostatics += integral(wholedomain, umesh, epsilon*grad(dof(vh))*grad(tf(vh)));
  154. helasticity += integral(solid, predefinedelasticity(dof(uh), tf(uh), u, E, nu, 0.0));
  155. // Here the electrostatic force must be computed using an FFT (on 5 timesteps)
  156. // because the force calculation involves nonlinear operations on multiharmonic fields:
  157. helasticity += integral(wholedomain, 5, umesh, predefinedelectrostaticforce(tf(uh,solid), grad(vh), epsilon));
  158. // The inertia term is added for the harmonic analysis:
  159. helasticity += integral(solid, -rho*dtdt(dof(uh))*tf(uh));
  160. // Generate and solve the electrostatic problem:
  161. helectrostatics.generate();
  162. vec solvh = solve(helectrostatics.A(), helectrostatics.b());
  163. vh.setdata(wholedomain, solvh);
  164. // Generate and solve the elasticity problem:
  165. helasticity.generate();
  166. vec soluh = solve(helasticity.A(), helasticity.b());
  167. uh.setdata(solid, soluh);
  168. uh.write(solid, umesh, "usmallsignal.pos");
  169. // Write the vibration at 50 timesteps of a period for a time visualization:
  170. (uh-uh.harmonic(1)).write(solid, umesh, "usmallsignal.pos", 1, 50);
  171. // Print the max AC deflection:
  172. double uacmax = abs(compy(uh.harmonic(2))).max(solid, 5)[0];
  173. std::cout << "Peak AC deflection: " << uacmax*1e9 << " nm" << std::endl;
  174. // Code validation line. Can be removed.
  175. std::cout << (uacmax < 1.1970e-09 && uacmax > 1.1967e-09);
  176. }
  177. // THE MESH BELOW IS FULLY STRUCTURED AND IS CREATED USING THE (BASIC) SPARSELIZARD GEOMETRY CREATION TOOL.
  178. // THE ADVANTAGE OF IT IS THAT THE CODE ABOVE CAN BE CALLED FOR ANY CMUT DIMENSION WITHOUT NEEDING CALLS TO EXTERNAL MESHING SOFTWARE.
  179. mesh createmesh(double r, double thmem, double thcav, double thins, double lpillar)
  180. {
  181. // Give names to the physical region numbers:
  182. int membrane = 1, pillar = 2, cavity = 3, ground = 4, electrode = 5, insulator = 6;
  183. // Number of mesh layers:
  184. int nx = 40, nzcavity = 5, nzmembrane = 6, nzinsulator = 3;
  185. int nxpillar = nx*lpillar/r;
  186. // Insulator:
  187. double h = -thins;
  188. shape q01("quadrangle", insulator, {0,h,0, r,h,0, r,h+thins,0, 0,h+thins,0}, {nx, nzinsulator, nx, nzinsulator});
  189. shape q02("quadrangle", insulator, {r,h,0, r+lpillar,h,0, r+lpillar,h+thins,0, r,h+thins,0}, {nxpillar, nzinsulator, nxpillar, nzinsulator});
  190. // Cavity layer:
  191. h = 0.0;
  192. shape q11("quadrangle", cavity, {0,h,0, r,h,0, r,h+thcav,0, 0,h+thcav,0}, {nx, nzcavity, nx, nzcavity});
  193. shape q12("quadrangle", pillar, {r,h,0, r+lpillar,h,0, r+lpillar,h+thcav,0, r,h+thcav,0}, {nxpillar, nzcavity, nxpillar, nzcavity});
  194. // Ground line:
  195. shape groundline("union", ground, {q01.getsons()[0], q02.getsons()[0]});
  196. // Membrane layer:
  197. h = h+thcav;
  198. shape q21("quadrangle", membrane, {0,h,0, r,h,0, r,h+thmem,0, 0,h+thmem,0}, {nx, nzmembrane, nx, nzmembrane});
  199. shape q22("quadrangle", membrane, {r,h,0, r+lpillar,h,0, r+lpillar,h+thmem,0, r,h+thmem,0}, {nxpillar, nzmembrane, nxpillar, nzmembrane});
  200. // Electrode line:
  201. shape electrodeline("union", electrode, {q21.getsons()[2], q22.getsons()[2]});
  202. // Provide to the mesh all shapes of interest:
  203. mesh mymesh({q01,q02,q11,q12,q21,q22,groundline,electrodeline});
  204. return mymesh;
  205. }
  206. int main(void)
  207. {
  208. SlepcInitialize(0,{},0,0);
  209. sparselizard();
  210. SlepcFinalize();
  211. return 0;
  212. }