COMSOL livelink with MATLAB 参数化扫描中避免内存不断增加
COMSOLCOMSOL与MATLAB是可以无缝连接的,有些图形化界面难以实施的操作可以通过MATLAB代码来实现。当我们通过MATLAB对COMSOL进行参数化扫描的时候,会发现随着时间的推移,内存会占用的越来越多,几乎是指数增加,如下图
具体如何绘制出这样一幅图可以见我的另外一片博客
个人博客地址从COMSOL的log文件读取运算时间和内存并绘图
知乎地址从COMSOL的log文件读取运算时间和内存并绘图
我们只需要在每一次循环扫描的时候,都将模型释放掉再重新Load一遍,内存增长的速度就会慢很多,如下图所示
具体的代码大致如下:
12345678910111213141516171819202122clear;clc;import com.comsol.model.*import com.comsol.model.util.*ModelUtil.showProgress('comsol_progress_inten_1.txt');% do some sweep herefor l=1:num % load the model % We will load the mo ...
Mathematica如何用来写Python并且二者之间进行数据转换
Mathematica前言 现如今Python很火,因为其入门简单,功能强大。在科学计算领域中也占有一席之地。本人作为量子光学领域的理论研究生,平时仿真软件(COMSOL,Lumerical)用的很多,MATLAB,Python以及Mathematica也用得勤。
个人体验来说,MATLAB,Python功能有重叠的地方,也有互相不可替代的地方。比如MATLAB与 COMSOL,Lumerical的Livelink就是我所需要的不可替代的功能,非常方便处理仿真数据。而对于一般的数据处理,MATLAB, Python我觉得不相伯仲。Python有一些开源的包,比如Qutip,在MATLAB里面已经停止维护了,所以想用Qutip还得用Python。
最后来说Mathematica,以前一直以为是个计算器,忽视了其作用,疫情期间花时间了解之后,知晓其功能之强大,也对Mathematica的创始人顶礼膜拜。Mathematica设计的初衷就是想做一个全能型选手,其在各个领域都有涉及,特别是符号计算,其编程的思路以及写程序的模式一旦适应,写起来真的很顺手。
为什么不直 ...
MATLAB与Python,Mathematica由高维转化一维矩阵的方式的不同点
MATLAB #Python #Dataprocessing在进行数据处理的时候,我比较喜欢的数据存储方式是所有的数据都保存成MATLAB的“.mat”文件,这种格式Python,Mathematica,MATLAB都会支持。不过在转化的时候得注意,特别是涉及到1维矩阵转化为多维矩阵的操作时,MATLAB与Pythonh,Mathematica有本质的不同,MATLAB是按照先“列”后“行”的顺序存数据的,而Mathematica和Python是按照先“行”后“列”的顺序存数据,具体的,我们可以用一个例子来说明:我们定义矩阵A,将A转化为1维矩阵A1D再转化回来为B.
MATLAB首先是MATLAB123A=[[1,2,3];[4,5,6];[7,8,9]];A1D=A(:);B=reshape(A,[3,3]);
123456789101112131415161718192021>> AA = 1 2 3 4 5 6 7 8 9>> A1D'ans = 1 4 7 ...
Direction in port-Plane wave input via port in COMSOL
Direction of input wave via port in COMSOL[TOC]
IntroductionIn COMSOL5.1, when we need input the plane wave from port, we need set the field expressions and the phase factors manually. In COMSOL 5.4, the evaluation angel $\alpha{1}$ and azimuthal angle $\alpha{2}$ are introduced to help us define the input angle. However, the definition of the angle combined with the field is not so easy. I spend a lot of time to learn and test the angle and then finally obtain the proper way to define the plan ...
Plane wave's transmission in a substate structure and its theoretical realization in COMSOL
Plane wave’s transmission in a substate structure and its theoretical realization in COMSOLDate:Create at: 2020 02 20Update at: 2020 08 20
IntroductionIn quantum nano optics, we often encounter this kind of problem:
Simulating the scattering of light by a nano objects on substrate.
The best way to simulate this kind of problem is the background field method since the enhancement of the light can be easily obtained. I use COMSOL to simulate this kind of problem and the simulation would be much fa ...
领域内大佬相关信息总结
这是为了收集自己研究相关的大佬或者相关组的一些信息以及代表作。
我会为这些人创建一个简单介绍以及代表作,代表工作。后续会更新他们的文章的一些介绍以及贡献。
也需要在google学术以及research gate上将他们动态实时掌握出来。
Franco NoriChief Scientist at RIKEN. Also, at the University of Michigan.
Google学术主页
Peter LodahlProfessor of Physics, Niels Bohr Institute, University of Copenhagen
Google学术主页
Niels Bohr Institute
Shanhui FanProfessor of Electrical Engineering, Stanford University
Google学术主页
Florian MarquardtMax Planck Institute for the Science of Light and University of Erlangen-Nuremberg
...
Installation of COMSOL
COMSOLOn UbuntuThe COMSOL installation package is a ISO file and we need mount it first. We create a empty folder first
1sudo mkdir /mnt/temp
Then we mount the ISO file and run the setup file
12sudo mount -o loop ./*.iso /mnt/tempsudo /mnt/temp/setup
During installation, we should
Choose the correct lic file
Cancel the update choice.
Cancel the un-needed modules.
For us the most import step is the installation of the COMSOL Livelink with MATLAB. We should choose the correct folder of the ...
How to use COMSOL on server
COMSOLThis note is to show the way of using COMSOL on our server (ubuntu). We hope that we can run them with bash code in background and after we logout or exit the server the simulations will continue. We also need to know the simulation progress from a log file. These needs can all be satisfied only if you write proper bash code.
Run COMSOL on serverIf you want to run COMSOL on server, you can use the command of the following form
1nohup comsol batch -inputfile <inputfilename> -outputf ...
COMSOL Problem List and Solutions
COMSOL[TOC]
IntroductionTo summarize the problems we often encountered in using COMSOL. I will update it later.
Problem 1 : No accumulated tables
Problem description:
We need define some global variables (such as the total power and radiative power) and when we do parameter sweep in COMSOL, an accumulated table should be generated to store the global variable. However, in a certain case when we have many tables in COMSOL and even if we have chosen the “Accumulated Table” to be ”New”, the table ...
Meep教程(1):在Ubuntu或者Windows的Ubuntu子系统的安装
Meep更新日志(2021 03 18)最近才知道自己以前安装的是非并行版本的Meep,为了不给大家造成困扰,我这里将以前的错误描述更正了。
(2023 04 22)最近发现官网的安装代码又有变化,按照老版本安装会有各种问题,所以我把安装代码也更新一下
(2023 09 23)近期安装发现,jupyter的安装有变化,依然使用以前的代码会导致安装不成功,这次将jupyter-notebook的安装更新完整了之前的安装命令是:1conda install jupyter
但最近安装有变化,根据jupyter最新的安装教程 :
1234567891011# 推荐使用conda forge源conda config --add channels conda-forgeconda config --set channel_priority strict# 如果安装jupyter notebookconda install notebook# 启动jupyter notebook# 如果是安装jupyterlabconda install jupyterlab# 启动jupyter lab
介绍 ...