Quantcast
Channel: Latest Discussions - COMSOL Forums
Viewing all 2194 articles
Browse latest View live

Using data from Matlab

$
0
0
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!

How to convert a fig file in matlab to comsol?

$
0
0
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!

Singularity error

$
0
0
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...

$
0
0
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.”

Error while using Matlab LiveLink

$
0
0
I'm facing a problem while using Matlab LiveLink.

--------------------------------------------------------------------------
geom1 = model.geom.create('geom1', 2);

c1 = geom1.create('c1', 'Circle');
c1.label('c1')
c1.set('r', '40');

c2 = geom1.create('c2', 'Circle');
c2.label('c2');
c2.set('r', '20');

dif1 = geom1.create('dif1', 'Difference');
dif1.selection('input').set(c1.label);
dif1.selction('input2').set(c2.label);
--------------------------------------------------------------------------

The code above gave the following error.

--------------------------------------------------------------------------
No method 'set' with matching signature found for class 'com.comsol.clientapi.impl.LocalGeomObjectSelectionClient'.

Error in
dif1.selection('input').set(c1.label);
--------------------------------------------------------------------------

Could anyone explain why this is happening?

Invoke parameters from comsol in matlab

$
0
0
Hi everyone,
I would like to invoke parameters from comsol in matlab, the code is as follows

model.param.set('N', '5');

num=model.param.N;

Error in num=model.param.N;

And how to invoke the parameter 'N' in matlab? Is there any other way to do this? Any help is appreciated.

assemble external force vector rather than the residual vector by comsol

$
0
0
Hi all,
In a simple linear elastic problem, a FE equation can be written as K*U=F, I would like to know if comsol can assemble and output this "F" vector?
In the documentation, it seems that comsol can output the residual vector "L" rather than "F".
Actually I need to output a vector which has the expression as: integrate(test(u)*w(x,y)) on domain or boundary, in which u is the dependent variable, and w(x,y) is the function I defined. I find this expression is in same format as the "F" vector mentioned above. So I need help to get the "F" vector or evaluate the vector with expression as integrate(test(u)*w(x,y)) directly.
Thank you all.

How to call external MATLAB functions from COMSOL?

$
0
0
Hello everyone,
I have a problem with calling an external MATLAB function from COMSOL model and I would be grateful for any assistance.
When I try to call an external MATLAB function from COMSOL I get an error which said:

"External MATLAB functions are disabled in the security preferences".

What does this security preferences mean? Due to this fact that I use Academic license for MATLAB, could it be the source of error? or I missed something else?

Kind regards,
Ebrahim

Comsol+Matlab on Linux cluster: "No user name and password could be obtained"

$
0
0
A problem I had and its solution, for the record. (Just seeing as nobody reported these error messages yet.)


Just tried running Comsol+Matlab on a cluster, using what seemed to work before:

$ \comsol server -tmpdir $TMPDIR < /dev/null > test2016apr01.log &

But Matlab said: "No user name and password could be obtained" after I entered "mphstart()".

So it turned out that Comsol server collapsed, and the log file said:

Username: Username: Username: Username: Username: Username: Username: Username: Username: Username: Made_X_attempts_at_obtaining_user_name._Giving_up#10


The way around this that I found was to first run Comsol server as follows:

$ \comsol mphserver -tmpdir $TMPDIR

It will then ask for a username and password. Luckily, it remembers these for the next time it runs, because it's not possible to connect to the above (at least with the way our cluster is set up, and probably others). So, shutting it down and running as follows, now works:

$ \comsol server -tmpdir $TMPDIR < /dev/null > test2016apr01.log &

$ matlab

Now, the right directory needs to be added to Matlab's PATH. For me this is /usr/local/comsol/5.1/mli but for others it's likely to be different. There is probably a way to permanently store this somehow, but I haven't found it yet. Post if you have a way (this is on Linux; it's easy on Windows).

Now this works:

>> mphstart()

CAD Import Module Error...

$
0
0
Hi,

I have created a CAD model and tried to import it into COMSOL, but I was encountered with this error:

''Feature: Import 1
CAD Import Module functionality is not installed.
Note: CAD Import Module functionality is included in the Design Module and the LiveLink products for
CAD''.

Now, I am not sure if there is simply a feature (Add-in) that needs to be activated or added to my current version of COMSOL (5.2), or I should have installed a completely different COMSOL version which would have had the CAD Import Module feature, in the first place?

Your help will be really appreciated.
Alireza

Variable boundary conditions

$
0
0
Hi all, I'm using the API to run my COMSOL model multiple times in a loop in MATLAB with different initial and boundary conditions.

I was just wondering if it would be possible to set the initial conditions from the last time step of the previous solution, and the boundary conditions as the time varying value of one of the independent variables at the last node point in my mesh.

The problem is one dimensional, and writing the conditions in as a polynomial function using polyval isn't ideal as this seems to produce ill conditioned polynomials with the data I have.

Basically, can you specify the initial and boundary conditions as arrays of values corresponding to either time steps or locations?

1GB MPH file resulting from importing a 4KB Image via MPHIMAGE2GEOM... Why?!

$
0
0
We are trying to import the attached small image into COMSOL using the mphimage2geom command in Matlab Livelink (relevant piece of code is below for your reference). The resulting mph file is over 1GB large, and takes forever to write. What is the cause of the huge file size, and how to avoid this?

COMSOL techsupport recommended importing the image using Functions>Image, and then "it will behave like a function". So does this mean that MPHIMAGE2GEOM is useless? Or am I using it in the wrong way somehow? Please explain...

Thanks.
-------------------------------------CODE BELOW-------------------------------------------------------
L = bwlabel(bw_image);

total_objects_number = max(unique(L)); %get the number of cells

for this_object_number = 1:total_objects_number

this_bw_object = L == this_object_number; %select THIS cell from GROUP of cells

%% obtain COMSOL geometry from image

img_geometry_MODEL_tag = ['Cell_' num2str(this_object_number)];

image_2_geom = mphimage2geom(this_bw_object,1,'Modeltag',img_geometry_MODEL_tag);

%INSERT this cell's COMSOL Geometry into the COMSOL model
model.geom('geom1').insertSequence(img_geometry_MODEL_tag,'geom1');

end

model.geom('geom1').run;

Solidworks import via CAD Import Module

$
0
0
Hi Folks,

It seems as though the CAD Import module cannot import Solidworks 2016 files, but LiveLink for SolidWorks can... is that a correct understanding?

I am just about to have my SolidWorks installation updated, but won't go for SolidWorks 2016 if the CAD Import Module does not support SolidWorks 2016 yet... (I do not have the LiveLink for SolidWorks module).

Could someone confirm the above?

Thanks in advance!

Mark

p.s. I have Comsol 5.2.0.220

p.p.s. The reason I ask is because there is ambiguity in the Product System Requirements, both the CAD Import module and the LiveLink for SolidWorks tables indicate support only up to SolidWorks 2015, yet the text in the LiveLink product page indicates support for SolidWorks 2016. Clarification greatly appreciated...

problem about comsol can't plot an external Matlab function that Nested a equations

$
0
0
Hi, everyone:

I have a problem about using an external matlab function that it nested another matlab function but comsol can't plot it.
this is my function:
>> function out = rho_x(T)
out=XSteam('rhoL_T',T);
%%XSteam is another M-File that contain a series of Material properties
This function can work in matlab,but not in comsol .
I have created another example to make out what is going on . That is :
>> function out = Cp_x(T)
out=CpL_x(T);
here is a M-File(CpL_x)
>>function out = CpL_x(T)
out=2+T.^2;
and is work ,that confused me a lot . Maybe something wrong about "XSteam('rhoL_T',T)", the 'rhoL_T' is just an char ,no an
numerical value.
Anyone with experience successfully doing this?

Thanks!
babyling

mphinterp - Read data from model fails: Error in meshextend: GC overhead limit exceeded

$
0
0
Hello,

I have encountered an error which I can not explain myself. I am calculating multiple models one after another with Matlab and read out data at specific coordinates.

This is part of my Matlab-Script:
dc_model; % Define Parameters, Geometry and Mesh, save model
for n = 1:204
...some stuff....
name = ['Homo-Model-',num2str(e1),'-',num2str(e2)];
solve_model; % Open meshed model, define physics, solve and save as name.mph
model = mphload(name); % load model
for m = 1:8
....some stuff...
mod_Vp(n,m)=mphinterp(model,'V','coord',[420;150;0]);
end
end

This worked fine up to n = 201. For n = 202 I get the following error:
Error using mphinterp
Java exception occurred:
Exception:
java.lang.RuntimeException: Error in meshextend: GC overhead limit exceeded
(rethrown as com.comsol.util.exceptions.FlException)
(rethrown as com.comsol.util.exceptions.FlException)
Messages:
Error in meshextend: GC overhead limit exceeded
Old model cannot be reconstructed. Do Clear Solution to expunge
Error in meshextend: GC overhead limit exceede
Error in run_model (line 76)
mod_Vp(n,m)=mphinterp(model,'V','coord',[420;150;0]);


For some reason I cannot attach the model ("File size error"...)
I hope someone can help.

Thanks,
Sina

MATLAB Function and Automating M-Script File with Comsol: mphinterp Command

$
0
0
I have used the command syntax: mphinterp(model,'p','coord',coord1a) to extract pressure values at the stated coordinates:
coord1a=[x1;y1].
The study is in 2D; but I have been getting an empty matrix message. Please, is there something wrong in my approach?

simulating an imported mesh (from matlab)

$
0
0
Hi,
I'm trying to simulate a prescribed displacement (one end is fixed and the other one displaced) of a mesh created in matlab (the geometry is from a microCT image). The problem is comsol dons't recognize the different surfaces. I used the box option in the mesh, but then the displacement is all messed up.
anyone has an experience with an imported mesh?
Thanks,
Shira

COmsol - Matlab Variable linking.

$
0
0
Hi all,

I am Looping simulations over matlab with different sets of values matlab calculates.
I am looking for changing the variable values. I have found for Parameter as
model.param.set() for changing the Parameter values. I am looking a similar solution for the variable in the model. I Need to replace this with the Array of values. This variable is an time dependent function. and I am running an transient Analysis.

Suggest me some Options and solution to overcome this.

I want to know whether my license is allowed to set up the comsol operated on a computer cluster

$
0
0
I do not know whether my license is allowed to set up the comsol operated on a computer cluster

How to define for comsol to use only one cpu for the solution? Also using the full memory.

$
0
0
When I run Comsol Sometimes I need it to work only with one CPU. Is there any option anywhere to do that or Comsol automatically decides on that?

Also for some solutions, I noticed my CPU is at 87% and memory is at 67%. How can change the settings so that it uses 100% of both?
Viewing all 2194 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>