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

How to plot time-dependent temperature profile at a point

$
0
0
Hi all,

I have 1 question over here, i have been using the SAR head tutorial (Provided by comsol tutorial) to do research for my school project and i have 1 problem over here which is, i cant seems to plot temperature VS time graph. i had searched though the internet for solution and i did follow their steps but still i cant manage to get it. whatever i try to plot, the time will varies but the temperature remains the same throughout which makes my curve looks like one horizontal straight line.

I will really appreciate if someone can take a look at the attached picture (i can't seems to upload my model file here) and suggest to me what should i do next.

Thanks,
Boon

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()

How to loop simulations in Comsol 4.2a with Matlab

$
0
0
Dear comsolers, here is an example on how to loop simulations. I'll let you decode it.

'Preprocessing' that I did before the loop:
1. Build a model in Comsol (attached).
2. Save As Model M-File (attached).
3. Open .m in Matlab and look for the line that needs to be modified on every loop. Note the line. Close .m.

The loop:
1. Start 'Comsol 4.2a with Matlab'.
2. Make sure that 'example.mph' is in the current folder.
3. Enter the following code and run it, it's an example of transient 1D heat transfer in solids where thermal conductivity is modified for each loop:

k = {'200[W/m/K]' '1000[W/m/K]' '2000[W/m/K]'}; % strings to pass to Comsol
for n = 1:length(k)
model = mphload('example.mph'); % load model
ModelUtil.showProgress(true) % display the progress bar
model.material('mat1').propertyGroup('def').set('thermalconductivity', {k{n} '0' '0' '0' k{n} '0' '0' '0' k{n}}); % this is the line I noted in the 'preprocessing', it's modified on every loop
model.sol('sol1').runAll; % solve
T(n) = mpheval(model,'T'); % extract and store data
kxx(n) = mpheval(model,'ht.kxx'); % extract and store data
ModelUtil.remove('model') % remove model because it will be reloaded on every loop
end


Question about nodes arrangement in model solutions with "mpheval" function (LiveLink with Matlab)

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






How to debug MATLAB function (COMSOL 4)

$
0
0
I am able to declare MATLAB function in comsol.

When I run comsol, it gives me error "Incorrect size of returned vector. 596 elements were expected, but the returned matrix was 1 x 1"

The error is OK because my function returns only 1 number, because I am trying to debug it and look on parameters passed by COMSOL. I opened function in MATLAB editor and put breakpoint on it. But it never stops on breakpoint.

In COMSOL 3.5 this works (put breakpoint in MATLAB function).

Is there possibility to trace MATLAB functions?

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

How to debug MATLAB function (COMSOL 4)

$
0
0
I am able to declare MATLAB function in comsol.

When I run comsol, it gives me error "Incorrect size of returned vector. 596 elements were expected, but the returned matrix was 1 x 1"

The error is OK because my function returns only 1 number, because I am trying to debug it and look on parameters passed by COMSOL. I opened function in MATLAB editor and put breakpoint on it. But it never stops on breakpoint.

In COMSOL 3.5 this works (put breakpoint in MATLAB function).

Is there possibility to trace MATLAB functions?

How to extract the stiffness Matrix for a certain element?

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

Bloch boundary condition in 2D phononic crystal

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

Java errors in Comsol 43 with matlab 2011b

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

Live Link for Matlab Help!

$
0
0

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 .
Viewing all 2194 articles
Browse latest View live


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