When i use the matlab function feature node in comsol 5.1 desk, the comsol alwarys prompt “Failure loading MATLAB libraries. This model requires that MATLAB is available.”
↧
When i use...
↧
How to extract the stiffness Matrix for a certain element?
Dear all,
Hi. I need to extract the stiffness Matrix for a certain element or node before assembling. The "mphmatrix" command gives me the results for whole geometry (After assembly). I wonder if there is any way for getting the matrix for certain elements? For example say that element number 2 or ... .
I appreciate your help,
Regards,
Masoud
Hi. I need to extract the stiffness Matrix for a certain element or node before assembling. The "mphmatrix" command gives me the results for whole geometry (After assembly). I wonder if there is any way for getting the matrix for certain elements? For example say that element number 2 or ... .
I appreciate your help,
Regards,
Masoud
↧
↧
How should I create an arbitrary 3D geometry object with contour coordinates
Since there is no more function like ' loft ' in 3.5a, how can I create a 3D geometry object with only the contour coordinates with only 4.2 functions? Can I convert a set of parallel polygons to a 3D geometry, by assigning each one with a z-axis height and combining all of them? Thank you all!
↧
Bloch boundary condition in 2D phononic crystal
Hi everyone,
I am trying to model a 2D phononic crystal in COMSOL. It is essentially a square with a hole at its center. Does anyone know how to set the Bloch boundary condition for the elastic PDE?
Here is the condition:
u(x)=u(x+R)exp(ik.R) or
usrc=udest*exp(ik.R).
where R is the lattice displacement vector.
Note that the normal PBC accessible from COMSOL does not have the phase factor.
Your help would be greatly appreciated.
I am trying to model a 2D phononic crystal in COMSOL. It is essentially a square with a hole at its center. Does anyone know how to set the Bloch boundary condition for the elastic PDE?
Here is the condition:
u(x)=u(x+R)exp(ik.R) or
usrc=udest*exp(ik.R).
where R is the lattice displacement vector.
Note that the normal PBC accessible from COMSOL does not have the phase factor.
Your help would be greatly appreciated.
↧
How to remove the history record in the m-file exported from COMSOL
Hello all,
I hope this is not a silly question. With "Save as Model M-file", COMSOL can generate a m-file that can be used in MATLAB with LiveLink.
But I realized that the generated m-file contains every step I did in COMSOL GUI. For example, if you set the Geometry Import several times in COMSOL, specified "1.mphbin" first, then imported. And you realized you chose the wrong file. You then changed to "2.mphbin", imported. You realized you did it wrong again.....
After changing the filename several times, you export the model to a m-file. It will look like:
model.geom('geom1').feature('wp1').geom.feature('imp1').set('filename', '1.mphbin');
model.geom('geom1').feature('wp1').geom.feature('imp1').importData;
model.geom('geom1').feature('wp1').geom.feature('imp1').set('filename', '2.mphbin');
model.geom('geom1').feature('wp1').geom.feature('imp1').importData;
model.geom('geom1').feature('wp1').geom.feature('imp1').set('filename', '3.mphbin');
model.geom('geom1').feature('wp1').geom.feature('imp1').importData;
model.geom('geom1').feature('wp1').geom.feature.remove('imp1');
model.geom('geom1').feature('wp1').geom.feature.create('imp1', 'Import');
model.geom('geom1').feature('wp1').geom.feature('imp1').set('filename', '1.mphbin');
model.geom('geom1').feature('wp1').geom.feature('imp1').importData;
model.geom('geom1').feature('wp1').geom.runAll;
But it is pretty clear that the first 7 lines don't make any sense. The problem not only exists for geometry, it also exists for mesh, solver, and so on.
Is there a way to remove all the history actions so I can get a clean m-file?
Thanks.
Best,
Kan
I hope this is not a silly question. With "Save as Model M-file", COMSOL can generate a m-file that can be used in MATLAB with LiveLink.
But I realized that the generated m-file contains every step I did in COMSOL GUI. For example, if you set the Geometry Import several times in COMSOL, specified "1.mphbin" first, then imported. And you realized you chose the wrong file. You then changed to "2.mphbin", imported. You realized you did it wrong again.....
After changing the filename several times, you export the model to a m-file. It will look like:
model.geom('geom1').feature('wp1').geom.feature('imp1').set('filename', '1.mphbin');
model.geom('geom1').feature('wp1').geom.feature('imp1').importData;
model.geom('geom1').feature('wp1').geom.feature('imp1').set('filename', '2.mphbin');
model.geom('geom1').feature('wp1').geom.feature('imp1').importData;
model.geom('geom1').feature('wp1').geom.feature('imp1').set('filename', '3.mphbin');
model.geom('geom1').feature('wp1').geom.feature('imp1').importData;
model.geom('geom1').feature('wp1').geom.feature.remove('imp1');
model.geom('geom1').feature('wp1').geom.feature.create('imp1', 'Import');
model.geom('geom1').feature('wp1').geom.feature('imp1').set('filename', '1.mphbin');
model.geom('geom1').feature('wp1').geom.feature('imp1').importData;
model.geom('geom1').feature('wp1').geom.runAll;
But it is pretty clear that the first 7 lines don't make any sense. The problem not only exists for geometry, it also exists for mesh, solver, and so on.
Is there a way to remove all the history actions so I can get a clean m-file?
Thanks.
Best,
Kan
↧
↧
Livelink for Matlab and COMSOL v4.2a Meshing and Solution not synchronized...
I have not found any discussion on this topic yet and I am having difficulty finding anyone in COMSOL support in North America that can help with this problem today.
Basically, I simply want to take a solution from COMSOL, import it into MATLAB and plot the solution on the mesh within MATLAB.
For an example problem:
1) I solve the 1D Helmholtz equation on a line segment from x=0...1, with Dirichlet boundary conditions at both ends.
*** I use the PDE Coefficient form setting the source term to zero (c=1,d_a=1,f=0). On a side note, I have tried to use the Helmholtz Equ "classic PDE" and it doesn't work (setting f=0) as it claims the "mass matrix is zero" - which is true, however, unnecessary when solving a sourceless problem (COMSOL please fix this).
*** I have also solved this for 2D and 3D as well, the problem I am describing still exists, but is harder to track down, read on....
2) Either export the solution to comsolserver or save the model as an mph file.
3) In Matlab (started from COMSOL with LiveLink for Matlab), load in the 1d Helmholtz solution:
either use:
fem1 = mphload('filename')
or use
fem1 = ModelUtil.model('Model');
4) load the solution vector (eigenvector) using either:
soltranspose = fem1.sol('sol1').getU(1);
or
soltranspose2 = mphgetu(fem1,'solnum',1)
5) load in the mesh using:
mesh1 = mphxmeshinfo(fem1,'solname', 'sol1');
6) set some variables for the x and y coordinates of the mesh (if you have a 2D mesh), if you have a 1D mesh, then only use the x coordinate:
xxx = mesh1.nodes.coords(1,:);
yyy = mesh1.nodes.coords(2,:);
it is good at this point to look at the mesh to verify that it is the same as in COMSOL:
plot(xxx,yyy,'.')
It looks good!
7) **** It is interesting to note that the solution vector coming from mphgetu is a column vector, but the mesh vector is a row vector. For this reason, I take the transpose of the solution vector to make it the same dimensions as the mesh vector.
8) Now, try to plot the solution for the 1D case:
solu = soltranspose';
plot(solu)
It looks good, like the correct answer should look, a half-wavelength eigenmode (the lowest mode).
9) Now try to plot the solution for the 1D case at the positions of the mesh:
plot(xxx,solu)
PROBLEM! The positions of the mesh are NOT ALIGNED with the solution vector. Although they both have the same size, the ordering of the mesh vector is not aligned to the ordering of the solution vector.
This is obvious when looking at the 1D solution to the Helmholtz equation, but is harder to trace when looking at a 2D or 3D solution.
So, WHY would you want to do this? In other words, why would I like to have total control over a solution from COMSOL? Simple, what if I wanted to perform my own ortho-normalization calculation. In this case, I would need to know the area around each point in the solution so that I could properly weight the integration (quadrature). There are many other reasons why I need to have the solution vector properly coordinated with the mesh, but that is the most obvious reason.
Any thoughts? Is there a property to the "mphxmeshinfo" structure that gives me the correct order for the mesh vector?
Help me Obiwan....
-KLM
Basically, I simply want to take a solution from COMSOL, import it into MATLAB and plot the solution on the mesh within MATLAB.
For an example problem:
1) I solve the 1D Helmholtz equation on a line segment from x=0...1, with Dirichlet boundary conditions at both ends.
*** I use the PDE Coefficient form setting the source term to zero (c=1,d_a=1,f=0). On a side note, I have tried to use the Helmholtz Equ "classic PDE" and it doesn't work (setting f=0) as it claims the "mass matrix is zero" - which is true, however, unnecessary when solving a sourceless problem (COMSOL please fix this).
*** I have also solved this for 2D and 3D as well, the problem I am describing still exists, but is harder to track down, read on....
2) Either export the solution to comsolserver or save the model as an mph file.
3) In Matlab (started from COMSOL with LiveLink for Matlab), load in the 1d Helmholtz solution:
either use:
fem1 = mphload('filename')
or use
fem1 = ModelUtil.model('Model');
4) load the solution vector (eigenvector) using either:
soltranspose = fem1.sol('sol1').getU(1);
or
soltranspose2 = mphgetu(fem1,'solnum',1)
5) load in the mesh using:
mesh1 = mphxmeshinfo(fem1,'solname', 'sol1');
6) set some variables for the x and y coordinates of the mesh (if you have a 2D mesh), if you have a 1D mesh, then only use the x coordinate:
xxx = mesh1.nodes.coords(1,:);
yyy = mesh1.nodes.coords(2,:);
it is good at this point to look at the mesh to verify that it is the same as in COMSOL:
plot(xxx,yyy,'.')
It looks good!
7) **** It is interesting to note that the solution vector coming from mphgetu is a column vector, but the mesh vector is a row vector. For this reason, I take the transpose of the solution vector to make it the same dimensions as the mesh vector.
8) Now, try to plot the solution for the 1D case:
solu = soltranspose';
plot(solu)
It looks good, like the correct answer should look, a half-wavelength eigenmode (the lowest mode).
9) Now try to plot the solution for the 1D case at the positions of the mesh:
plot(xxx,solu)
PROBLEM! The positions of the mesh are NOT ALIGNED with the solution vector. Although they both have the same size, the ordering of the mesh vector is not aligned to the ordering of the solution vector.
This is obvious when looking at the 1D solution to the Helmholtz equation, but is harder to trace when looking at a 2D or 3D solution.
So, WHY would you want to do this? In other words, why would I like to have total control over a solution from COMSOL? Simple, what if I wanted to perform my own ortho-normalization calculation. In this case, I would need to know the area around each point in the solution so that I could properly weight the integration (quadrature). There are many other reasons why I need to have the solution vector properly coordinated with the mesh, but that is the most obvious reason.
Any thoughts? Is there a property to the "mphxmeshinfo" structure that gives me the correct order for the mesh vector?
Help me Obiwan....
-KLM
↧
Implementation of constitutive relations from MATLAB
Hey all
I have a material model that links the material stresses to the material strains coded in a MATLAB function that I would like to link to a COMSOL model. As I see it there are two ways - but I am not sure and would like to have your opinion on the best procedure:
1) use the external material node in COMSOL, which requires me to first wrap the MATLAB code in a C file and subsequently create a dll.
2) through live link - though I have never used it before and I'm not sure if there is a way to link a material model that way easily.
Is there any other way to do this? Maybe someone could point me in the right direction. Any help is greatly appreciated.
I have a material model that links the material stresses to the material strains coded in a MATLAB function that I would like to link to a COMSOL model. As I see it there are two ways - but I am not sure and would like to have your opinion on the best procedure:
1) use the external material node in COMSOL, which requires me to first wrap the MATLAB code in a C file and subsequently create a dll.
2) through live link - though I have never used it before and I'm not sure if there is a way to link a material model that way easily.
Is there any other way to do this? Maybe someone could point me in the right direction. Any help is greatly appreciated.
↧
Assembling different imported solidworks files into COMSOL
Hi,
Wondering how we are able to assemble different imported parts in COMSOL in a fashionable manner?
Thanks
Wondering how we are able to assemble different imported parts in COMSOL in a fashionable manner?
Thanks
↧
Live connection with matlab
Hi every one
i am working with live connection comsol with matlab . when i want to make optimization by using optimization tool for 7 variable on my model . after some time of working it gives me this error
(line 143)
Java exception occurred:
Exception:
com.comsol.util.exceptions.LicenseException: Could not
obtain license for X Required product#Terminal 1#AC/DC
Module
(rethrown as com.comsol.util.exceptions.FlException)
(rethrown as com.comsol.util.exceptions.FlException)
Messages:
Could not obtain license for X Required product#Terminal
1#AC/DC Module
Could not obtain license for X Required product#Terminal
1#AC/DC Module
Could not obtain license for 'Terminal 1'.
Required product: AC/DC Module.
License error: -15.
Cannot connect to license server system.
i have the license for comsol 5.2 and matlab 2015b, i don't know why ?
can anyone help me with this problem
thank you
i am working with live connection comsol with matlab . when i want to make optimization by using optimization tool for 7 variable on my model . after some time of working it gives me this error
(line 143)
Java exception occurred:
Exception:
com.comsol.util.exceptions.LicenseException: Could not
obtain license for X Required product#Terminal 1#AC/DC
Module
(rethrown as com.comsol.util.exceptions.FlException)
(rethrown as com.comsol.util.exceptions.FlException)
Messages:
Could not obtain license for X Required product#Terminal
1#AC/DC Module
Could not obtain license for X Required product#Terminal
1#AC/DC Module
Could not obtain license for 'Terminal 1'.
Required product: AC/DC Module.
License error: -15.
Cannot connect to license server system.
i have the license for comsol 5.2 and matlab 2015b, i don't know why ?
can anyone help me with this problem
thank you
↧
↧
how to save the comsol model detail in matlab and recall that model in other function
I know hoe to set previous comsol result as my current initial value in COMSOL. when I transfer to matlab file. I am wandering is there any way to save the comsol model as a structure or something else so I can recall the solution when i am running other functions. just like in COMSOL 3.5, we can save fem structure. is there anything similar to that in COMSOL 5.2?
Thanks in advance,
Ying
Thanks in advance,
Ying
↧
Question about nodes arrangement in model solutions with "mpheval" function (LiveLink with Matlab)
Dear colleagues, I need your adviсe!
I work with Solid Mechanics and Pressure acoustic modules. I use LiveLink with Matlab to extract solution data from the Comsol model (v.5.2). I defined a parametric curve in the solid part of the model geometry. And now I'm able to extract deformation data along the curve using "mpheval" function with 'selection' property.
According to the LiveLink datasheet "mpheval" returns the structure 'pd' that contains many fields and among them: pd.p and pd.t. It's known that:
- p contains the node point coordinates information. The number of rows in p is the number of space dimensions;
- t contains the indices to columns in pd.p of a simplex mesh; each column in pd.t represents a simplex;
The problem is that all node points and their coordinatetes in pd.p and pd.t placed in wrong order! It can be seen if you plot them.
How can I reconstruct my parametric curve and its coordinates by using pd.t or in another way?
I work with Solid Mechanics and Pressure acoustic modules. I use LiveLink with Matlab to extract solution data from the Comsol model (v.5.2). I defined a parametric curve in the solid part of the model geometry. And now I'm able to extract deformation data along the curve using "mpheval" function with 'selection' property.
According to the LiveLink datasheet "mpheval" returns the structure 'pd' that contains many fields and among them: pd.p and pd.t. It's known that:
- p contains the node point coordinates information. The number of rows in p is the number of space dimensions;
- t contains the indices to columns in pd.p of a simplex mesh; each column in pd.t represents a simplex;
The problem is that all node points and their coordinatetes in pd.p and pd.t placed in wrong order! It can be seen if you plot them.
How can I reconstruct my parametric curve and its coordinates by using pd.t or in another way?
↧
Errors in COMSOL with Matlab
When I launch COMSOL with MATLAB I get the following errors. Have any of you had this problem or know what is wrong?
2016-02-12 00:34:55.590:INFO:oejs.Server:jetty-8.y.z-SNAPSHOT
2016-02-12 00:34:56.197:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:31415
2016-02-12 00:34:56.310:INFO:oejus.SslContextFactory:Enabled Protocols [SSLv2Hello, TLSv1, TLSv1.1, TLSv1.2] of [SSLv2Hello, SSLv3, TLSv1, TLSv1.1, TLSv1.2]
2016-02-12 00:34:56.319:INFO:oejs.AbstractConnector:Started SslSocketConnector@0.0.0.0:61415
I am running COMSOL 5.1 and MATLAB_R2015b on a MacBook Pro with OS X El Capitan 10.11.3.
Thanks!
2016-02-12 00:34:55.590:INFO:oejs.Server:jetty-8.y.z-SNAPSHOT
2016-02-12 00:34:56.197:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:31415
2016-02-12 00:34:56.310:INFO:oejus.SslContextFactory:Enabled Protocols [SSLv2Hello, TLSv1, TLSv1.1, TLSv1.2] of [SSLv2Hello, SSLv3, TLSv1, TLSv1.1, TLSv1.2]
2016-02-12 00:34:56.319:INFO:oejs.AbstractConnector:Started SslSocketConnector@0.0.0.0:61415
I am running COMSOL 5.1 and MATLAB_R2015b on a MacBook Pro with OS X El Capitan 10.11.3.
Thanks!
↧
which version is compatible with matlab R2011b?
please help me with this problem. I want to know which version is compatible with matlab R2011b.
COMSOL Multiphysics 5.0 is employed, but it not OK.
COMSOL Multiphysics 5.0 is employed, but it not OK.
↧
↧
Java errors in Comsol 43 with matlab 2011b
When I use matlab2011b to run M-file generated by comsol43 in Linux system, the following massages appear:
"Java exception occurred:
java.lang.RuntimeException: Could not start the server.
at com.comsol.model.clientserver.ClientManagerImpl.launchServer(Unknown Source)
at com.comsol.model.util.ModelManager.create(Unknown Source)
at com.comsol.model.util.ModelInternalUtil.create(Unknown Source)
at com.comsol.model.util.ModelInternalUtil.create(Unknown Source)
at com.comsol.model.util.ModelUtil.create(Unknown Source)
Error in rect_hole_centerline_182to196_193to199_125to141_sio (line 16)
model = ModelUtil.create('Model');
Username: Username: Username: Username: Username: Username: Username: Username: Username: Username:
ERROR: Could not start COMSOL Application. See log file: /home/common/.comsol/v43/logs/server9.log"
Could anyone give me some suggestion?
"Java exception occurred:
java.lang.RuntimeException: Could not start the server.
at com.comsol.model.clientserver.ClientManagerImpl.launchServer(Unknown Source)
at com.comsol.model.util.ModelManager.create(Unknown Source)
at com.comsol.model.util.ModelInternalUtil.create(Unknown Source)
at com.comsol.model.util.ModelInternalUtil.create(Unknown Source)
at com.comsol.model.util.ModelUtil.create(Unknown Source)
Error in rect_hole_centerline_182to196_193to199_125to141_sio (line 16)
model = ModelUtil.create('Model');
Username: Username: Username: Username: Username: Username: Username: Username: Username: Username:
ERROR: Could not start COMSOL Application. See log file: /home/common/.comsol/v43/logs/server9.log"
Could anyone give me some suggestion?
↧
Live Link for Matlab Help!
Hello everyone , I have a problem with a live link for matlab probably due to my lack of experience with the software and would like your advice : I made a time-dependent model and I want to analyze the contour of a drop of water in an oil matrix. I want to , with the help of Livelink , extrapolate in one step isolines of all instants of time , but after making the connection between MATLAB and COMSOL sever and after importing the model , when I insert the command to do that :
data = mpheval (model , ' con1 ' , ' t ' , [ 1.1,25.6 ] )
matlab answer me with this error :
" Undefined variable
variable = ' con1 '
Geometry = geom1
domain = 2
expression in error = real ( con1 )
help me .
It is a no adaptive mesh model , because by doing this with the adaptive mesh model did not make the evaluation because of different mesh .
↧
Using data from Matlab
Dear all Comsol users,
To make the question simple, a heat transfer model is set up in 2-D, and every step, I want to calculate the heat source term in Matlab (which will be a 2-D matrix), then send this heat source term back to Comsol.
Currently, from what I found online, the most viable way seems to be setting up a interpolation function. But my concern is that, for a 2-D problem, the interpolation function in Comsol seems to require the data source to be from 'file' instead of table (for 'table' I can set it in Matlab code). This means that I need to save this heat source term matrix from Matlab to hard drive, then read it again in Comsol every step. Will this be very slow? Or is there a better way to do this?
Thanks!
To make the question simple, a heat transfer model is set up in 2-D, and every step, I want to calculate the heat source term in Matlab (which will be a 2-D matrix), then send this heat source term back to Comsol.
Currently, from what I found online, the most viable way seems to be setting up a interpolation function. But my concern is that, for a 2-D problem, the interpolation function in Comsol seems to require the data source to be from 'file' instead of table (for 'table' I can set it in Matlab code). This means that I need to save this heat source term matrix from Matlab to hard drive, then read it again in Comsol every step. Will this be very slow? Or is there a better way to do this?
Thanks!
↧
How to convert a fig file in matlab to comsol?
Recently, I build a 2D image through a matlab function file. Now I want to analysis it in comsol, but I failed to import it. I don't want to convert it to a dxf file. I have read a lot words about the livelink help, still don't know how to import it when calling a function.Can anyone help me? Thanks a lot!
↧
↧
Parameter optimization and access to Matlab's global variables
Hello everyone,
I'm simulating a mold where there is heat flux on different circles (cf picture).
I would like to have an homogenous temperature on the surface of the mold. That is to say, minimize the difference of temperatures between the left side and the right side. For this optimization, my parameters are the position of the circles (named e1, e2, e3... e7).
I have decided to use the function 'fminsearch' this way :
. Function which allows me to have the difference of temperatures
function Temp=opt_chauffe(e1,e2,e3,e4,e5,e6,e7)
model=model2
Temp=Temp1-Temp2;
end function
. function fminsearch :
fminsearch(opti_chauffe,[0.05, 0.12, 0.16, 0.22, 0.24, 0.26, 0.27]);
1) First of all, my function 'opt_chauffe' doesn't work
Indeed, I have this error :
??? Undefined function or variable 'e1'.
Error in ==> model2 at 71
model.geom('geom1').feature('c2').set('pos', [e1 0]);
Error in ==> opt_chauffe at 3
model=model2
-> So I think that my model doesn't recognize the matlab variable of my function. How can I solve it?
2)I don't know if the function 'fminseach' is a good way to solve this problem. Can you help me?
Thank you
Best regards
Yoan
I'm simulating a mold where there is heat flux on different circles (cf picture).
I would like to have an homogenous temperature on the surface of the mold. That is to say, minimize the difference of temperatures between the left side and the right side. For this optimization, my parameters are the position of the circles (named e1, e2, e3... e7).
I have decided to use the function 'fminsearch' this way :
. Function which allows me to have the difference of temperatures
function Temp=opt_chauffe(e1,e2,e3,e4,e5,e6,e7)
model=model2
Temp=Temp1-Temp2;
end function
. function fminsearch :
fminsearch(opti_chauffe,[0.05, 0.12, 0.16, 0.22, 0.24, 0.26, 0.27]);
1) First of all, my function 'opt_chauffe' doesn't work
Indeed, I have this error :
??? Undefined function or variable 'e1'.
Error in ==> model2 at 71
model.geom('geom1').feature('c2').set('pos', [e1 0]);
Error in ==> opt_chauffe at 3
model=model2
-> So I think that my model doesn't recognize the matlab variable of my function. How can I solve it?
2)I don't know if the function 'fminseach' is a good way to solve this problem. Can you help me?
Thank you
Best regards
Yoan
↧
Singularity error
Hi,
when I use Matlab to run the COMSOL simulation, I am getting the error :
Repeated error test failures. May have reached a singularity.
But when I directly use COMSOL to run the simulation, it works fine.
Any suggestion? Thanks in advance.
when I use Matlab to run the COMSOL simulation, I am getting the error :
Repeated error test failures. May have reached a singularity.
But when I directly use COMSOL to run the simulation, it works fine.
Any suggestion? Thanks in advance.
↧
When i use...
When i use the matlab function feature node in comsol 5.1 desk, the comsol alwarys prompt “Failure loading MATLAB libraries. This model requires that MATLAB is available.”
↧