首页 > 其他分享 >相场模拟——枝晶生长(COMSOL模拟雪花形成)

相场模拟——枝晶生长(COMSOL模拟雪花形成)

时间:2023-07-16 16:55:41浏览次数:38  
标签:枝晶 COMSOL create component param set model comp1 模拟

一、介绍

1.1 物理含义

雪花是人们最常见的枝晶。枝晶生长是一种生长的不稳定现象,常起因于过冷的液体,或晶体的生长速度受限于溶质原子向固体表面的扩散速度。造成以上条件的原因,可以是液相中负的温度梯度,也可以是负的浓度梯度。在这种模式下,晶体倾向于在其棱角处优先生长,从而形成突触状结构。

这篇博文会介绍用相场模拟的方法,模拟雪花生长的过程。

1.2 相场模拟介绍

在相场法中,使用连续变量描述微观结构特征。这些变量有两种形式:代表物理性质的守恒变量,如原子浓度或材料密度;描述材料微观结构(包括晶粒和不同相)的非守恒序参数(order parameters)。这些连续变量的演化用自由能的函数表达,可以定义为一个PDE偏微分方程系统。该相场模型还可以与其他物理相耦合,例如力学或热传导。这些模型方程可以用多种方法求解,包括有限差分法、谱方法和有限元法。

相场PDE是各种变量的演化方程,是自由能泛函F的函数。

对于守恒变量(conserved variables),其满足Cahn-Hilliard方程:

其中ci是保守变量,Mi是相应的迁移率。

对于非保守量,其满足 Allen-Cahn方程:

ηj是序参量,Lj是序参数的迁移率。

 自由能函数包括局部自由能,梯度自由能,以及系统的其它额外自由能(比如电势能,弹性势能等等)。可以用如下公式计算:

f_loc: local free energy density; f_gr: gradient energy density; Ed: additional sources of energy in the system, such as deformation or electrostatic energy.

 

二、枝晶生长模型

模型包含两个变量: 相场θ(r, t),温度场T(r, t)

θ = 0 表示液态;θ = 1 表示固态;

PDE:

其它方程:

 

三、COMSOL建模

1.      建立一个2D,两个变量的General Form PDE模型(自变量为theta, T),瞬态求解。

 

 2.      Global Definition-> Parameters

K 1.8 1.8
TAU 0.0003 3E-4
EPS 0.01 0.01
DELTA 0.02 0.02
ANGLE0 1.57 1.57
ANISO 6 6
ALPHA 0.9 0.9
GAMMA 10.0 10
TEQ 1.0 1

 

 

 

4.      Model -> Definition -> Variables

epsilon EPS*(1+DELTA*cos(ANISO*(angle-ANGLE0)))
epsilonp -EPS*ANISO*DELTA*sin(ANISO*(angle-ANGLE0))
epsilon2 epsilon*epsilon
m ALPHA/pi*atan(GAMMA*(TEQ-T)) rad
angle if(abs(thetax)>eps,atan2(thetay,thetax)+pi*(atan2(thetay,thetax)<0),pi/2*((thetay>0)+3*(thetay<0))) rad

 

5.      Geometry

建立一个关于原点对称的9×9矩形

 

6.      PDE设置

 

 

初始值

 

7. Mesh

建立Mapped型网格,Maximum element size为0.1(可适当加密,0.06~0.08左右效果比较好)

 

 8.      Study求解时间为range(0,0.1,0.3)

 

导出的部分matlab代码:

function out = model
%
% crystalGrowth.m
%
% Model exported on Jul 16 2023, 16:41 by COMSOL 6.0.0.318.

import com.comsol.model.*
import com.comsol.model.util.*

model = ModelUtil.create('Model');

model.component.create('comp1', true);

model.component('comp1').geom.create('geom1', 2);

model.component('comp1').mesh.create('mesh1');

model.component('comp1').physics.create('g', 'GeneralFormPDE', {'theta' 'T'});

model.study.create('std1');
model.study('std1').create('time', 'Transient');
model.study('std1').feature('time').setSolveFor('/physics/g', true);

model.param.set('K', '1.8');
model.param.set('TAU', '0.0003');
model.param.set('EPS', '0.01');
model.param.set('DELTA', '0.02');
model.param.set('ANGLE0', '1.57');
model.param.set('ANISO', '6');
model.param.set('ALPHA', '0.9');
model.param.set('GAMMA', '10.0');
model.param.set('TEQ', '1.0');

model.func.create('step1', 'Step');
model.func('step1').set('location', 0.09);
model.func('step1').set('from', 1);
model.func('step1').set('to', 0);
model.func('step1').set('smooth', 0.05);

model.variable.create('var1');
model.variable.remove('var1');
model.component('comp1').variable.create('var1');

model.component('comp1').geom('geom1').run;

model.component('comp1').variable('var1').set('epsilon', 'EPS*(1+DELTA*cos(ANISO*(angle-ANGLE0)))');
model.component('comp1').variable('var1').set('epsilonp', '-EPS*ANISO*DELTA*sin(ANISO*(angle-ANGLE0))');
model.component('comp1').variable('var1').set('epsilon2', 'epsilon*epsilon');
model.component('comp1').variable('var1').set('m', 'ALPHA/pi*atan(GAMMA*(TEQ-T))');
model.component('comp1').variable('var1').set('angle', 'if(abs(thetax)>eps,atan2(thetay,thetax)+pi*(atan2(thetay,thetax)<0),pi/2*((thetay>0)+3*(thetay<0)))');

model.component('comp1').geom('geom1').create('r1', 'Rectangle');
model.component('comp1').geom('geom1').feature('r1').set('size', [9 9]);
model.component('comp1').geom('geom1').runPre('fin');
model.component('comp1').geom('geom1').run;

model.component('comp1').physics('g').feature('gfeq1').setIndex('Ga', {'-thetax*epsilon2+epsilon*epsilonp*thetay' '-thetay'}, 0);
model.component('comp1').physics('g').feature('gfeq1').setIndex('Ga', {'-thetax*epsilon2+epsilon*epsilonp*thetay' '-thetay*epsilon2-epsilon*epsilonp*thetax'}, 0);
model.component('comp1').physics('g').feature('gfeq1').setIndex('f', 'd(epsilon2,x)*thetax+d(epsilon2,y)*thetay+theta*(1-theta)*(theta-0.5+m)', 0);
model.component('comp1').physics('g').feature('gfeq1').setIndex('f', 0, 1);
model.component('comp1').physics('g').feature('gfeq1').setIndex('da', 'TAU', 0);
model.component('comp1').physics('g').feature('gfeq1').setIndex('da', '-K', 1);
model.component('comp1').physics('g').feature('init1').set('theta', 'step1(x^2+y^2)');

model.component('comp1').mesh('mesh1').create('size1', 'Size');
model.component('comp1').mesh('mesh1').feature.remove('size1');
model.component('comp1').mesh('mesh1').create('map1', 'Map');
model.component('comp1').mesh('mesh1').feature('size').set('hmax', 0.1);
model.component('comp1').mesh('mesh1').feature('size').set('hmin', '6.75e-4');
model.component('comp1').mesh('mesh1').feature('size').set('hgrad', 1.2);
model.component('comp1').mesh('mesh1').feature('size').set('hcurve', 0.25);
model.component('comp1').mesh('mesh1').run;

model.sol.create('sol1');
model.sol('sol1').study('std1');

model.study('std1').feature('time').set('notlistsolnum', 1);
model.study('std1').feature('time').set('notsolnum', 'auto');
model.study('std1').feature('time').set('listsolnum', 1);
model.study('std1').feature('time').set('solnum', 'auto');

model.sol('sol1').create('st1', 'StudyStep');
model.sol('sol1').feature('st1').set('study', 'std1');
model.sol('sol1').feature('st1').set('studystep', 'time');
model.sol('sol1').create('v1', 'Variables');
model.sol('sol1').feature('v1').set('control', 'time');
model.sol('sol1').create('t1', 'Time');
model.sol('sol1').feature('t1').set('tlist', 'range(0,0.1,1)');
model.sol('sol1').feature('t1').set('plot', 'off');
model.sol('sol1').feature('t1').set('plotgroup', 'Default');
model.sol('sol1').feature('t1').set('plotfreq', 'tout');
model.sol('sol1').feature('t1').set('probesel', 'all');
model.sol('sol1').feature('t1').set('probes', {});
model.sol('sol1').feature('t1').set('probefreq', 'tsteps');
model.sol('sol1').feature('t1').set('atolglobalvaluemethod', 'factor');
model.sol('sol1').feature('t1').set('endtimeinterpolation', true);
model.sol('sol1').feature('t1').set('control', 'time');
model.sol('sol1').feature('t1').create('fc1', 'FullyCoupled');
model.sol('sol1').feature('t1').feature('fc1').set('linsolver', 'dDef');
model.sol('sol1').feature('t1').feature.remove('fcDef');
model.sol('sol1').attach('std1');

model.result.create('pg1', 'PlotGroup2D');
model.result('pg1').set('data', 'dset1');
model.result('pg1').create('surf1', 'Surface');
model.result('pg1').feature('surf1').set('expr', 'theta');

model.sol('sol1').runAll;

  

 

 

四、结果

 

 

 

 

 

参考:

https://mooseframework.inl.gov/modules/phase_field/Phase_Field_Equations.html

https://mooseframework.inl.gov/modules/phase_field/Derivation_explanations.html

https://blog.sina.com.cn/s/blog_4a0a8b5d01011spl.html

标签:枝晶,COMSOL,create,component,param,set,model,comp1,模拟
From: https://www.cnblogs.com/spacerunnerZ/p/17557921.html

相关文章

  • 2023.07.16 高质量 NOIP 模拟赛题解
    HDU5719Arrange【模拟】给定数列\(B_n,C_n\),求出满足\[B_i=\min_{j=1}^i\{A_j\},\quadC_i=\max_{j=1}^i\{A_j\}\]的排列\(A\)的数量。维护每个位置可能的数字数量,然后乘法原理即可。代码:http://acm.hdu.edu.cn/viewcode.php?rid=38654445。HDU5807KeepInTouch......
  • HHHOJ #1247. 「NOIP 2023 模拟赛 20230715 A」1 题解--zhengjun
    法老找来的题,说是找了三道其他模拟赛的T4拼成T1~T3,另外搞了道T4。思维好题,但是放在T1有点搞心态,但是还好大样例够强,400没挂。然而T3大样例输出错了,浪费了我0.5h,差评。首先发现向左走之后向右走是一定不优的,所以最短路的情况只能先向右再向左。考虑枚举起点\(s......
  • 模拟退火
    引入模拟退火是一种随机化算法,当一个问题方案数量极大且非单峰时,我们常使用模拟退火过程先引入几个参数:当前最优解\(E_0\),新解\(E\),解变动量\(\DeltaE\)(即\(E\)与\(E_0\)的差),上一个被接受的解\(E_1\),初温\(T_0\),末温\(T_k\),当前温度\(T\),温度变动量\(\Delt......
  • [YDRG#001] 提瓦特环游记 · 云斗杯 · 七月 Golden 组模拟赛 整理分析--zhengjun
    link总体评价:因为K了,所以好评,练一下思维蛮好的,质量不错比赛2.5hK的。#A.诗人小G初进OI界标准送分,输出\(\frac{s_2-a_2}{a_1}\)。#include<bits/stdc++.h>usingnamespacestd;usingll=longlong;constintN=1e6+10;intn,a[N];voidread(ll&x){ char......
  • vue-day16---模拟一个数据监测
    <!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"/><title>模拟一个数据监测你</title></head><body><scripttype="text/javascript">letdata={......
  • 【雕爷学编程】Arduino动手做(162)---OPT101模拟光照传感器模块3
    37款传感器与执行器的提法,在网络上广泛流传,其实Arduino能够兼容的传感器模块肯定是不止这37种的。鉴于本人手头积累了一些传感器和执行器模块,依照实践出真知(一定要动手做)的理念,以学习和交流为目的,这里准备逐一动手尝试系列实验,不管成功(程序走通)与否,都会记录下来—小小的进步或是......
  • 【雕爷学编程】Arduino动手做(162)---OPT101模拟光照传感器模块2
    37款传感器与执行器的提法,在网络上广泛流传,其实Arduino能够兼容的传感器模块肯定是不止这37种的。鉴于本人手头积累了一些传感器和执行器模块,依照实践出真知(一定要动手做)的理念,以学习和交流为目的,这里准备逐一动手尝试系列实验,不管成功(程序走通)与否,都会记录下来—小小的进步或是搞......
  • 模拟
    模拟T14682粒子运动 因为题目数据不大,所以直接枚举两个点,看看哪两个点是距离最近的两个点。然后用一个结构体来存储点的坐标,然后里面的运算就和平面向量的计算是一样的。 这里要注意的是这里的所有基本都是\(double\),不要忘记了把结构体里面重载运算符的地方改成\(doubl......
  • 2023冲刺国赛模拟 36.1
    最近越来越懒了,估了很长时间的题解,OI生涯结束前是凑不够200篇博客了,但退役前还是努力写点东西吧。第一次写题解的大约在暑假集训,原因是当时改模拟赛题目经常参考学长的博客,于是自己也尝试这写了博客;然而省选以后,改题就很少参考学长的博客,一个原因是很难找到模拟赛题目的题解,......
  • 【考后总结】7 月多校国赛模拟赛 3
    7.14冲刺国赛模拟36T1染色题关键性质是奇数偶数位上可以放置的只有两种,若\(i\)和\(i-2\)选的颜色不同,那么在\(i\)位置放一个球,\([l,r]\)的限制等价于\([l+2,r]\)中奇数位和偶数位不同时有球。设\(f_i\)为\(i\)放置一个球的合法方案数,这样直接枚举上一个球所在......