This page has these goals:
Now that you have the GUI on the screen, you can now access the documentation. See below for more pointers on that. The most important parts of the GUI of COMSOL Multiphysics are the large work plane to draw the domain of the PDE and the pull-down menues Draw, Physics, Mesh, Solve, and Postprocessing. These menues correspond to the 5 basic steps necessary to solve a problem in COMSOL. The following list gives an example.
The following example is the Poisson equation -div(grad(u))=f with f(x,y) = (pi^2/2)*(cos(pi*x)*(cos(pi*y/2))^2+(cos(pi*x/2))^2*cos(pi*y)) in the domain (-1,1)x(-1,1) with homogeneous Dirichlet boundary condition (BC) u=0.
To confirm that this is an appropriate result, we can refine the mesh once by secting Mesh > Refine Mesh, then solving again by selecting Solve > Solve Problem, and then computing the domain integral of the squre of the error again. This gave 1.340048e-10 on my computer and thus sqrt(1.340048e-10)=1.157604e-5 for the error norm. The ratio of the error on the coarse mesh divided by this error on the fine mesh is 9.425176e-5/1.157604e-5=8.141969. This means that by halving the mesh spacing in the uniform refinement process, we reduced the error by a factor of about 8, which agrees with the theoretical expectation of cubid convergence for quadratic Lagrange elements.
comsol batch driver_getfemNotice that the argument is the name of the script driver_getfem, which is the file name driver_getfem.m without the extension .m. COMSOL will now run and output to the shell windows whatever it would output in the Script or MATLAB window.
nohup comsol batch driver_getfem >& driver_getfem.log &runs COMSOL in batch mode in the background and captures all screen output to the file driver_getfem.log. This is suitable for long runs, e.g., overnight of COMSOL.
C>> h_getfem = 'getfem_cos_mod' h_getfem = getfem_cos C>> nrefmax = 8 nrefmax = 6 C>> h_utrue = '(cos(pi*x/2))^2*(cos(pi*y/2))^2' h_utrue = (cos(pi*x/2))^2*(cos(pi*y/2))^2 C>> [N,D,E,R,Q] = driver_getfem_mod (h_getfem, nrefmax, h_utrue); r N D E R Q 0 4 5 2.9263e-001 NaN NaN 1 8 13 2.0899e-001 1.4002e+000 4.8562e-001 2 16 41 7.3679e-002 2.8365e+000 1.5041e+000 3 32 145 2.0178e-002 3.6515e+000 1.8685e+000 4 64 545 5.2376e-003 3.8526e+000 1.9458e+000 5 128 2113 1.3264e-003 3.9486e+000 1.9813e+000 6 256 8321 3.3300e-004 3.9833e+000 1.9940e+000 7 512 33025 8.3358e-005 3.9948e+000 1.9981e+000 C>> [N,D,E,R,Q] = driver_getfem_mod (h_getfem, nrefmax); r N D E R Q 0 4 5 2.7731e-001 NaN NaN 1 8 13 1.5046e-001 1.8431e+000 8.8210e-001 2 16 41 5.3111e-002 2.8330e+000 1.5024e+000 3 32 145 1.4555e-002 3.6488e+000 1.8674e+000 4 64 545 3.7743e-003 3.8564e+000 1.9473e+000 5 128 2113 9.5361e-004 3.9579e+000 1.9847e+000 6 256 8321 2.3594e-004 4.0418e+000 2.0150e+000 7 512 33025 5.4898e-005 4.2977e+000 2.1036e+000
C>> h_getfem = 'getfem_cos_mod_2' h_getfem = getfem_cos_mod_2 C>> [N,D,E,R,Q] = driver_getfem_mod (h_getfem, nrefmax, h_utrue); r N D E R Q 0 4 13 1.7392e-001 NaN NaN 1 8 41 3.1510e-002 5.5196e+000 2.4646e+000 2 16 145 3.8044e-003 8.2825e+000 3.0501e+000 3 32 545 5.1077e-004 7.4484e+000 2.8969e+000 4 64 2113 6.5472e-005 7.8013e+000 2.9637e+000 C>> h_getfem = 'getfem_cos_mod_3' h_getfem = getfem_cos_mod_3 C>> [N,D,E,R,Q] = driver_getfem_mod (h_getfem, nrefmax, h_utrue); r N D E R Q 0 4 25 7.1091e-002 NaN NaN 1 8 85 6.5707e-003 1.0819e+001 3.4356e+000 2 16 313 6.4204e-004 1.0234e+001 3.3553e+000 3 32 1201 4.0756e-005 1.5753e+001 3.9776e+000 4 64 4705 2.5597e-006 1.5922e+001 3.9929e+000 C>> h_getfem = 'getfem_cos_mod_4' h_getfem = getfem_cos_mod_4 C>> [N,D,E,R,Q] = driver_getfem_mod (h_getfem, nrefmax, h_utrue); r N D E R Q 0 4 41 1.2803e-002 NaN NaN 1 8 145 9.0950e-004 1.4077e+001 3.8153e+000 2 16 545 2.7186e-005 3.3454e+001 5.0641e+000 3 32 2113 8.9823e-007 3.0267e+001 4.9197e+000 4 64 8321 2.8497e-008 3.1520e+001 4.9782e+000 C>> h_getfem = 'getfem_cos_mod_5' h_getfem = getfem_cos_mod_5 C>> [N,D,E,R,Q] = driver_getfem_mod (h_getfem, nrefmax, h_utrue); r N D E R Q 0 4 61 8.1515e-003 NaN NaN 1 8 221 9.2938e-005 8.7708e+001 6.4546e+000 2 16 841 2.5066e-006 3.7078e+001 5.2125e+000 3 32 3281 3.9463e-008 6.3517e+001 5.9891e+000 4 64 12961 6.1840e-010 6.3815e+001 5.9958e+000These results show that the L2-norm of the error in the solution of the FEM with Lagrange elements with shape functions of polynomial degree p converges with order p+1 for this test smooth test problem. This is consistent with the theory for higher-order elements, assuming its boundary is smooth.
This demonstration used the fact that the true solution is known for this test problem. It is not readily clear how to estimate the error precisely enough, if the true solution is not known.
C>> h_getfem = 'getfem_del_disk' h_getfem = getfem_del_disk C>> nrefmax = 5 nrefmax = 5 C>> h_utrue = '-log(sqrt(x^2+y^2))/(2*pi)' h_utrue = -log(sqrt(x^2+y^2))/(2*pi) C>> [N,D,E,R,Q] = driver_getfem_mod (h_getfem, nrefmax, h_utrue); r N D E R Q 0 8 9 4.2659e-002 NaN NaN 1 16 25 2.1727e-002 1.9634e+000 9.7334e-001 2 32 81 1.0827e-002 2.0067e+000 1.0048e+000 3 64 289 5.4008e-003 2.0048e+000 1.0035e+000 4 128 1089 2.6990e-003 2.0010e+000 1.0008e+000 C>> h_getfem = 'getfem_del_disk_2' h_getfem = getfem_del_disk_2 C>> [N,D,E,R,Q] = driver_getfem_mod (h_getfem, nrefmax, h_utrue); r N D E R Q 0 8 25 2.6621e-002 NaN NaN 1 16 81 1.1271e-002 2.3619e+000 1.2400e+000 2 32 289 5.6492e-003 1.9952e+000 9.9652e-001 3 64 1089 2.8240e-003 2.0004e+000 1.0003e+000 4 128 4225 1.4120e-003 2.0000e+000 1.0000e+000 C>> h_getfem = 'getfem_del_disk_3' h_getfem = getfem_del_disk_3 C>> [N,D,E,R,Q] = driver_getfem_mod (h_getfem, nrefmax, h_utrue); r N D E R Q 0 8 49 2.3227e-002 NaN NaN 1 16 169 1.2267e-002 1.8934e+000 9.2098e-001 2 32 625 6.1349e-003 1.9996e+000 9.9972e-001 3 64 2401 3.0674e-003 2.0000e+000 1.0000e+000 4 128 9409 1.5337e-003 2.0000e+000 1.0000e+000 C>> h_getfem = 'getfem_del_disk_4' h_getfem = getfem_del_disk_4 C>> [N,D,E,R,Q] = driver_getfem_mod (h_getfem, nrefmax, h_utrue); r N D E R Q 0 8 81 9.1463e-003 NaN NaN 1 16 289 3.3492e-003 2.7309e+000 1.4494e+000 2 32 1089 1.6752e-003 1.9993e+000 9.9950e-001 3 64 4225 8.3758e-004 2.0000e+000 1.0000e+000 4 128 16641 4.1879e-004 2.0000e+000 1.0000e+000 C>> h_getfem = 'getfem_del_disk_5' h_getfem = getfem_del_disk_5 C>> [N,D,E,R,Q] = driver_getfem_mod (h_getfem, nrefmax, h_utrue); r N D E R Q 0 8 121 1.0465e-002 NaN NaN 1 16 441 5.2186e-003 2.0053e+000 1.0038e+000 2 32 1681 2.6100e-003 1.9995e+000 9.9962e-001 3 64 6561 1.3050e-003 2.0000e+000 1.0000e+000 4 128 25921 6.5250e-004 2.0000e+000 1.0000e+000