Daniel1985的个人博客分享 http://blog.sciencenet.cn/u/Daniel1985

博文

COMSOL 个人笔记

已有 26255 次阅读 2013-3-17 23:06 |个人分类:MATLAB/COMSOL|系统分类:科研笔记| MATLAB, COMSOL


0. 内部函数汇总


solid.epe = solid 模块下的 “等效塑性应变”



1.COMSOL with MATLAB 中模块系数的输入有的是以矩阵形式填写的,那么导入 MATLAB 之后将按什么顺序呢?

答案是以列的形式,即 {a11; a21; a12; a22;} 的顺序。


2. 求解器选择


源于 COMSOL v4.3 Nonlinear Structural Material ModulePlasticitybar_necking:

The Double dogleg solver is suitable for highly non-linear problems.

具体设置位置:

1 In the Model Builder window, right-click Study 1 and choose Show Default Solver.

2 Expand the Solver 1 node.

3 In the Model Builder window, expand the Study 1>Solver Configurations>Solver

1>Stationary Solver 1 node, then click Fully Coupled 1.

4 In the Fully Coupled settings window, click to expand the Method and Termination

section.

5 From the Nonlinear method list, choose Double dogleg.


3. 参数扫掠设置

1 In the Model Builder window, under Study 1 click Step 1: Stationary.

2 In the Stationary settings window, click to expand the Study Extensions section.

3 Select the Continuation check box.

4 Click Add.

5 In the table, enter the following settings:

6 ......


4. 输出云图时,去掉模型边界

Locate the Plot Settings section. Clear the Plot data set edges check box.

Click the Plot button.


5. 云图镜像设置,以xy为对称面为例

同样地,要是以平面问题旋转为三维云图,可以通过 data sets 下的 Revolution 设置。

Data Sets

1 In the Model Builder window, expand the Results>Data Sets node.

2 Right-click Data Sets and choose More Data Sets>Mirror 3D.

3 In the Mirror 3D settings window, locate the Plane Data section.

4 From the Plane list, choose xy-planes.


Stress, 3D (solid)

1 In the Model Builder window, under Results click Stress, 3D (solid).

2 In the Mirror 3D settings window, locate the Data section.

3 From the Data set list, choose Mirror 3D 1.


6. COMSOL 案列库中找 PDE 例子


   MODEL LIBRARY > COMSOL MULTIPHYSICS > EQUATION-BASED MODELS


7.

参数化循环求解


   其实如果你对一个参数扫描的话,COMSOL的GUI是可以实现参数化的,

   在求解器菜单下,你可以找找,只    需要保存你的参数扫描和解就可以了。


   但是如果你对几个参数扫描或者一个参数很复杂的扫描的话,建议你使用Matlab进行二次开发。

   关于这样的案例,你可以参考RF模块,"band gaps of photonic" 这个案例,不是瞬态的,

   但是研究透了,对你的问题应该很大帮助。


   quote:"http://forum.simwe.com/forum.php?mod=viewthread&tid=945665&extra=page%3D3%26filter%3Dtypeid%26typeid%3D335%26typeid%3D335"


8. PDEs中添加if条件


   if(cond,expression,expression), like if(x<0, y=a, y=b)

   意思是 当 x<0时 y=a 否则 y=b;

   但是这种方法对求解的自变量并不适合,

   因为这个只能加载到边界条件中,而求解域只接受初值问题。


9. 分步求解,如何取前pde结果作后面pde计算初始值


问:求教:如果分步求解,想取前面pde计算的结果作为后面pde计算的初始值怎么实现?

   我尝试了一下,稳态求解解不出。

   用瞬态求解发现:前pde求解参数在后面pde里面作为初始值显示是零,

   而不是其求解得到的结果。


答:在之前计算好的求解器中右键solver 选择solution>copy,这时会生成新的保存解;

   然后在你马上要选择计算的求解器中点开dependent variables,method 选择solution,

   solution中选择之前保存的解就可以了。这个在化工模块中的热分解案例有操作。


   quote:http://forum.simwe.com/forum.php?mod=viewthread&tid=1040251&extra=page%3D2%26filter%3Dtypeid%26typeid%3D323%26typeid%3D323



10. matlab函数调用时的方程编写


   由于在comsol中,无论变量是一个值,还是一个数组,comsol内部都将用数组的形式来保存,因此在matlab函数的调用中,运算符号必须用数组的运算符号,而非矩阵、或者标量的运算符,如:


function H=Hfunction(T,d)


H=3*T./(4*d)-T.^3./(4*d.^3)+1/2;

H(T>=d)=1;

H(T<=-d)=0;


即使 d 是一标量,但是函数表达式中,变量间相乘/除、或者乘方,均需要加“ . ”来处理。



11. 初始场施加

例:计算以温度场1(稳态分析)作为温度场2的初始温度场进行瞬态分析。


a. 稳态分析

假设稳态温度场,变量为T,用study,step1=stationary;

step1中,Physics and Variables Selection中,选择第一个温度场,去掉第二个温度场;

直接计算第一个Study。


b. 以上述的稳态温度场,添加到第二个瞬态温度场中变量为T2;

建立瞬态温度场,初始边界条件,即Initial Values,填T(重要!);

新建另外一个study,step1=Time Dependent;

step1中,Physics and Variables Selection中,选择第二个温度场,去掉第二个温度场;

右键第二个Study,Show Default Solver;

Study → Solver Configuration → Solver → Dependent Variables →

Initial Values of Variables Solved For:

Method = Initial expression(一般默认就是这个选项);

Solution = Solver( 即第一个稳态分析的Solver,重要! );

直接计算第二个Study。

(注:用1个Study,2个step也是可以完成的)


12. COMSOL调用MATLAB函数时引起的为指定导数问题

全局变量中增加 MATLAB function → Settings 窗口中

Functions 正常填写,如 Function Name = Ca_fun,Arguments = porosity,theta;

Derivatives  则需对应每一变量填写 函数对任一自变量的导数,可以通过再调用 MATLAB 函数的办法,

若不考虑导数,则填 0 ,如:

Function name = Ca_fun, Arguments = porosity, Partial derivative = 0;

Function name = Ca_fun, Arguments = theta, Partial derivative = 0.


 






https://blog.sciencenet.cn/blog-626917-671243.html

上一篇:COMSOL with MATLAB 帮助文件例子
下一篇:word2010没首页页码设置问题
收藏 IP: 113.140.84.*| 热度|

1 刘洋

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-7-23 03:33

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部