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

Running the simulation for the required time span in more than one times (loops)

$
0
0
Dear sir,

My requirement is "Running the simulation for the required time span in more than one times (loops)".

I actually do not know the initial values of temperatures of the room that I am going to analyse on CFD. So, I wish to run it for more that one times (or you can say loops) so as to stabilise my results and compare them with the real world ones. Is it possible and how should I do it??

meshing with Livelink

$
0
0
Dear sir,
I have a major problem concerning the livelink.
I will explain to you:
I have a 2D plasma model of width 0.42m and height 0.144 m, I mesh the model with element size of order 10^-4m but at differnt sizes, so there are 646533 mesh elements in the domain.
When I use the matlab code to run comsol it gives 'solver run out of memory' , though I have saved the meshing in the model, and hence I do not create the meshing in matlab.
I tried two cases

1- use command : model.mesh('mesh1').run;
2-do not use command : model.mesh('mesh1').run;

To tell you that the code is written well it runs well when meshing is of order 10^-3 and without using the command model.mesh('mesh1').run;

What do you think?
I really need a solution to this problem since I have to run thousands of simulations.
Best Regards
Mervat

Tutorial: Working between COMSOL 4.1 and MATLAB 2010b

$
0
0
Ok, here is what I figured out in order to be able to take a COMSOL model, modify it in MATLAB and then reopen it in COMSOL for further work:

1. Launch COMSOL normally;
2. Launch MATLAB by using "COMSOL 4.1 with MATLAB";

In COMSOL:
- Saving your current COMSOL model into the COMSOL server:
a) File > Export Model to Server...
(Default settings: Server = localhost, Port = 2036)
Model = <filename> (Ex.: shell_diffusion)

(At that point, your COMSOL model is in the COMSOL server/buffer and is named "shell_diffusion")

In MATLAB:
- Loading your COMSOL model that you sent in the COMSOL server:
>> model = ModelUtil.model('shell_diffusion');
- Saving the file as a MATLAB .m-file:
>> model.save(<filename>, 'm'); (Ex.: model.save('shell_diffusion2', 'm'); )
(The file would be saved by default in the current working folder)
- In order to save the file in a specific folder:
>> model.save('C:\COMSOL_Models\shell_diffusion2', 'm');

(You now have created a MATLAB .m-file from a COMSOL file which you can edit and modify)
(I know, you could have just use the File > Save as Model M-File... option in COMSOL but I don't know how you could resend it to COMSOL that way)

- To save your modified model back into COMSOL:
>> model.save('C:\COMSOL_Models\shell_diffusion3'); (No specific file extension will save it as a .mph COMSOL file)

(You now have your COMSOL file back which you can reopen in COMSOL)

Problem with create new solution in comsol 4.1

$
0
0
Hi
I have problem with crating a solution using script in Comsol 4.1. In help I read that Comsol enabled functionality to manipulate solutions (see help model.sol). I want to creates a solution object from more than one solutions. The Comsol provides function model.sol(<tag>).createSolution(). In accordingly with the Comosol Manual a new created solutions is based on the input from the following sets (real and imaginary components) setU(int,double[]),setPNames(String[]),setPVals(double[]),setPVals(int,double[]) The solution is created at this stage. Afterwards the user input is cleared. If a created solution is used before this function is run the result is unpredictable. When I call createSolution function we get following exception:
??? Java exception occurred:
Exception:
java.lang.NullPointerException
(rethrown as com.comsol.util.exceptions.FlException)
Messages:

Stack trace:
at com.comsol.model.impl.SolverSequenceImpl.K(Unknown Source)
at com.comsol.model.impl.SolverSequenceImpl.createSolution(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.comsol.clientserver.impl.JobImpl.run(Unknown Source)
at com.comsol.server.internal.b.a(Unknown Source)
at com.comsol.server.internal.b.a(Unknown Source)
at com.comsol.server.internal.b$h.a(Unknown Source)
at com.comsol.server.internal.b$h.a(Unknown Source)
at com.comsol.server.internal.b$h$a.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Error in ==> przyklad at 147
model.sol('sol3').createSolution()
model.study.create('std3');
model.study('std3').feature.create('time', 'Transient');
model.study('std3').feature('time').set('tlist', {'0','0.1','0.2'});
model.sol.create('sol3');
model.sol('sol3').study('std3');
model.sol('sol3').feature.create('st1', 'StudyStep');
model.sol('sol3').feature('st1').set('study', 'std3');
model.sol('sol3').feature('st1').set('studystep', 'time');
model.sol('sol3').feature.create('v1', 'Variables');
model.sol('sol3').feature.create('t1', 'Time');
model.sol('sol3').feature('t1').set('tlist', {'0','0.1','0.2'});

%Create new solution
model.sol('sol3').setPNames(model.sol('sol2').getPNames());
model.sol('sol3').setPVals([0.0045,0.005,0.0055]);
model.sol('sol3').setPValsImag([0.0045,0.005,0.0055]);
model.sol('sol3').setU(1,model.sol('sol1').getU(1));
model.sol('sol3').setUImag(1,model.sol('sol1').getUImag(1));
model.sol('sol3').setU(2,model.sol('sol2').getU(2));
model.sol('sol3').setUImag(2,model.sol('sol2').getUImag(2));
model.sol('sol3').setU(3,model.sol('sol2').getU(3));
model.sol('sol3').setUImag(3,model.sol('sol2').getUImag(3));
model.sol('sol3').createSolution();

The sol1 and sol2 consist a results of calculation.
Can you help me!!! What should I do to create a new solution properly without any exception using script Comsol 4.1??

Matlab functions in Comsol - limited compared to 3.5?

$
0
0
Dear All,

I'm running Comsol 4.1 via the LifeLink from Matlab. Basically it works fine but I encountered a limitation, which was not present in the version 3.5.
I have a Matlab function which sets up the Comsol model object based on an input image. This is realized with the following way:
- Matlab reads in image information from an image data file
- Matlab sets up the Comsol model geometry (via Lifelink) based on this image
- mesh, physics, solvers, etc are also set by Matlab
- a Matlab function is defined, which is giving back the material property at a location (x,y,z) based on the image information. This function should be called from Comsol during runtime for each element, but this function should still be connected to Matlab (from which the Lifelink was started) as the image information is read and stored there and this function should access this image-based information during execution of the Comsol solution.

In the old (3.5) version it was possible to have a such a Matlab function in the material definition fields of Comsol.
In the new (4.1) version I cannot make it work.

What I could do is to define a Matlab function within the Comsol model object, like this:

% MATLAB CODE
extm1=model.func.create('extm1', 'MATLAB');
extm1.setIndex('funcs', 'simple_function', 0, 0);
extm1.setIndex('funcs', 'x', 0, 1);
% END MATLAB CODE

This way Comsol will be able to recognize the function 'simple_function(x)' (if it's in the Matlab path) and I can then use it to define material properties as a function of 'x', e.g. like this (just a dummy example):

% MATLAB CODE
mName='MYmat';
model.material.create(mName);
model.material(mName).name(mName);
model.material(mName).materialModel.create('Orthotropic', 'Orthotropic');
Ex = '100001';
Ey = '100002';
Ez = 'simple_function(x)';
...
... definitions of nu_ii and G_ii are done here
...
model.material(mName).materialModel('Orthotropic').set('Evector', {Ex, Ey, Ez});
model.material(mName).materialModel('Orthotropic').set('nuvector', {nuxy, nuyz, nuxz});
model.material(mName).materialModel('Orthotropic').set('Gvector', {Gxy, Gyz, Gxz});
model.material(mName).selection.set('1');
% END MATLAB CODE

This way 'Ez' will be defined by 'simple_function(x)'.

BUT. The problem is that - as far as I have understood - Comsol calls a 'new' Matlab to evaluate the function 'simple_function(x)'. This 'new' Matlab cannot communicate with the 'original' Matlab (I mean from which Comsol Lifelink was started and where the image data is stored a global variable).
Therefore 'simple_function(x)' will not have access to the image data from which it should read the material property information

Could you please help me with this issue?

Thanks a lot in advance,
Peter

Error: Unknown property: funcname

$
0
0
Hi,

I have defined a MATLAB function which is called by COMSOL. I get an error message such as:

Undefined value found.
- Detail: Undefined value found in the equation residual vector.
There are 2128 degrees of freedom giving NaN/Inf in the vector for the variable mod1.solid.pw
at coordinates: (0.452,0), (0. 448,0), ….

In the meantime, when I try to get a Report from my model in Results/Report, I receive such an error:

Unknown Property
Property: funcname

I think I have properly implemented the MATLAB function (regardless of how it calculates the things for me, because I get the above error).

Does anyone know what this error means?

Thanks,
Jessica

Link Matlab to Comsol in MAC - path problem

$
0
0
Dear all,

in the bin/comsol.ini file I defined

MLROOT=/Applications/MATLAB_R2011b.app

The problem is that when clicking the app COMSOL with Matlab a problem appears.
checking the setlog I says something like


the path is not found: applications/matlab_R2011.app/bin/bin/matlab.

Then I check in matlab and actually I onlye have the path: applications/matlab_R2011.app/bin/matlab.

As you can see only one "bin" folder appears not 2. So I guess the solution is to fix the comsol.ini file and put one bin folder but I don't know how to do it.

any help

How to export data in excel format?

$
0
0
Hey Ivar,
I want to export my figure into excel format. and replot it in matlab. Is it possible ?
Thank you very much!!

Baofeng

Parallel computing MatLab Comsol

$
0
0
Hi,

I am using Comsol 4.3 with Livelink for Matlab. I run an optimization code in Matlab where i call Comsol to perform frequency response simulations. Now i would like to start two parallel frequency response simulations that are independent of each other from my Matlab code.
My approach so far has been to open another Matlab worker by using matlabpool and parfor. However, only one of the Matlab workers are then connected to Comsol. Is it possible to perform parallel computing in Comsol when using the Matlab livelink?

//Anders

Error to initialize a physics interface created with Physics Builder in LiveLink for Matlab

$
0
0
Hi all,
I am trying to compile with LiveLink for Matlab (Matlab version MATLAB_R2012a) a Comsol model (Comsol version COMSOL 4.3.0.151) that uses a physics interface which I created with the Physics Builder.

I have already exported the physics interface as a plugin and included it into the COMSOL installation. It works in Comsol. The problem is when I try to compile the *.m-file in Matlab. Errors are as follows:

Error using com.comsol.model.impl.PhysicsListImpl/create
Java exception occurred:
Exception:
    com.comsol.util.exceptions.FlException: Unknown physics interface
    (rethrown as com.comsol.util.exceptions.FatalReInitializeException)
Messages:
    Failed to initialize physics interface

    Unknown physics interface
    - Physics interface: PhysicsInterfaceName

Stack trace:
    at com.comsol.model.internal.physics.impl.PhysicsImpl.a(Unknown Source)
    at com.comsol.model.internal.physics.impl.PhysicsImpl.initialize(Unknown Source)
    at com.comsol.model.internal.impl.PhysicsListImpl.a(Unknown Source)
    at com.comsol.model.internal.impl.PhysicsListImpl.a(Unknown Source)
    at com.comsol.model.internal.impl.PhysicsListImpl$d.a(Unknown Source)
    at com.comsol.model.internal.impl.PhysicsListImpl$d.execute(Unknown Source)
    at com.comsol.model.clientserver.ClientManagerImpl$d.call(Unknown Source)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: Exception:
    com.comsol.util.exceptions.FlException: Unknown physics interface
Messages:
    Unknown physics interface
    - Physics interface: PhysicsInterfaceName

at com.comsol.model.applapi.ApplModeCreatorManager.getApplID(Unknown Source)
    at com.comsol.model.applapi.ApplModeCreatorManager.create(Unknown Source)
    ... 12 more

Error in test_43 (line 20)
model.physics.create('TagName', 'PhysicsInterfaceName', 'GeometryName');

Does anyone have a similar problem?

Thank's in advance,

Savitri

COMSOL 4.3 with MATLAB error

$
0
0
I have a problem with COMSOL 4.3 with matlab simulation.

The error message is below.



??? Java exception occurred:
Exception:
java.lang.RuntimeException:
java.lang.reflect.InvocationTargetException
(rethrown as com.comsol.util.exceptions.FlException)
Messages:
java.lang.reflect.InvocationTargetException


Stack trace:

at com.comsol.clientserver.impl.JobImpl.run(Unknown Source)

at com.comsol.server.internal.b.a(Unknown Source)

at com.comsol.server.internal.b.a(Unknown Source)

at com.comsol.server.internal.b$a.a(Unknown Source)

at com.comsol.server.internal.b$a.a(Unknown Source)

at com.comsol.server.internal.b$a$a.run(Unknown Source)

at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
Source)

at
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
Source)

at java.lang.Thread.run(Unknown Source)

Caused by: java.lang.reflect.InvocationTargetException

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown
Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
Source)

at java.lang.reflect.Method.invoke(Unknown Source)

... 9 more

Caused by: java.lang.OutOfMemoryError: GC overhead limit
exceeded

at java.util.Arrays.copyOf(Unknown Source)

at java.util.ArrayList.ensureCapacity(Unknown Source)

at java.util.ArrayList.addAll(Unknown Source)

at
com.comsol.nativeutil.properties.bm.getAllProperties(Unknown
Source)

at
com.comsol.nativeutil.properties.r.getFromAllProperty(Unknown
Source)

at com.comsol.model.internal.impl.PropFeatureImpl.a(Unknown
Source)

at com.comsol.model.internal.impl.PropFeatureImpl.a(Unknown
Source)

at com.comsol.model.internal.impl.PropFeatureImpl.j(Unknown
Source)

at
com.comsol.model.internal.impl.PropFeatureImpl.generateKey(Unknown
Source)

at com.comsol.post.numerical.h.a(Unknown Source)

at com.comsol.post.numerical.h.a(Unknown Source)

at com.comsol.post.numerical.h.a(Unknown Source)

at com.comsol.post.numerical.h.getReal(Unknown Source)

at
com.comsol.model.internal.impl.NumericalFeatureImpl.a(Unknown
Source)

at
com.comsol.model.internal.impl.NumericalFeatureImpl.getReal(Unknown
Source)

... 13 more




I have for loop code.
It works several loops normally.
But it stopped the middle of the loop process
I can't find the what the problem is.
May I get the solution?

Kyungnam Kang

MATLAB Livelink

$
0
0
Hi

I am running a MATLAB script from COMSOL with MATLAB, and it eats up all memory in C drive. so it never returns any result before it crashes.

Any idea why this happen? something wrong with the script? something unresolved from COMSOL with MATLAB side? my COMSOL model is too big in terms of size?

Appreciate any insights. Many thanks in advance!

regards
Liwah

COMSOL 4.3 with MATLAB error 2

$
0
0
I have the code that have for loop.
Before the first loop is finished, we met several error messages




??? Error using ==> mphinterp at 317
mphinterp (292): Java exception occurred:
Exception:
java.lang.RuntimeException: Error in reInitializeModel
(rethrown as com.comsol.util.exceptions.FlException)
Messages:
Error in reInitializeModel






??? Error using ==> mphinterp at 317
mphinterp (292): Java exception occurred:
Exception:
java.lang.NullPointerException
(rethrown as com.comsol.util.exceptions.FlException)
Messages:





??? Error using ==> mphinterp at 317
mphinterp (292): Java exception occurred:
Exception:
org.eclipse.emf.cdo.common.util.TransportException: java.util.concurrent.TimeoutException
(rethrown as com.comsol.util.exceptions.FlException)
Messages:
java.util.concurrent.TimeoutException



Is it a memory problem?
We have a 16GB RAM.
I increased the java memory to 7GB.
But, I have that problem continually.
May I get the solution?

Kyungnam Kang

Integration of MATLAB functions with more than one variable

$
0
0
Hi,
I want to realize an integration in COMSOL 4.3a using self-written MATLAB functions.

If I use a test function with one input and one output argument everything works as expected (plotting function, integration).
If I now use a function with two arguments I still can plot the function with respect to x and y, but I will get an error when trying to do an integration:
"Evalutation of result expression - Unknown function or operator."

As I said I can plot the function correctly, so it can be found. And on the other hand functions are also found in integration when using a function with one argument.

Any ideas what could be wrong and what the solution could be?

Best,
Erik

COMSOL 4.3 with MATLAB error

$
0
0
I have the code that have for loop.
Before the first loop is finished, we met several error messages




??? Error using ==> mphinterp at 317
mphinterp (292): Java exception occurred:
Exception:
java.lang.RuntimeException: Error in reInitializeModel
(rethrown as com.comsol.util.exceptions.FlException)
Messages:
Error in reInitializeModel






??? Error using ==> mphinterp at 317
mphinterp (292): Java exception occurred:
Exception:
java.lang.NullPointerException
(rethrown as com.comsol.util.exceptions.FlException)
Messages:





??? Error using ==> mphinterp at 317
mphinterp (292): Java exception occurred:
Exception:
org.eclipse.emf.cdo.common.util.TransportException: java.util.concurrent.TimeoutException
(rethrown as com.comsol.util.exceptions.FlException)
Messages:
java.util.concurrent.TimeoutException



Is it a memory problem?
We have a 16GB RAM.
I increased the java memory to 7GB.
But, I have that problem continually.



Mattia replied below.


Error using ==> mphinterp

here is where you shuold look for your error :-)



But I think that the code 'mphinterp' is not the reason of error.

When I simulate short loops about ~1600, I could get a results
However, if I increase the loops over the 1600, I could not get the results with above error message.

I think that it is not the problem about the code.

May I get the solution?




Kyungnam Kang


Problem with Convergence

$
0
0
I was running my HT+NITF model for simulation for 2 days. But, still I was not able to obtain the convergence. The progress of my simulation after 2 days of running is as follows (in the picture "Untitled.jpg).. Please let me know how to attain convergence... I am unable to make changes as I was being suggested each correction at each point of problem which is not working out perfectly. The log information at this stage is as follows... (Log data at 4.02 PM 19th feb.jpg).

Please help me out in getting a solution.



Segregated Solver, Segregated group

$
0
0
What is the meaning of "Segregated Solver" and "Segregated Group"?

While computing for the results, I am getting a line like follows... "Segregated Solver 17% Step 3" .
And the value beside Step in that line is varying between 1, 2 & 3.

Does the step in that line mean "time step"?
As i have a time step of 300 sec spanning from 0 sec to 86400 sec, total 288 step.
So, will need to go through 288 steps??

Pipe Flow Module

$
0
0
Can anybody let me know how to use pipe flow module in COMSOL 4.3a starting from basics with an example??

Problems Converting .mph to .m

$
0
0
Hi all,

I am working within the fluid-structure interaction module in COMSOL. I would like to vary one of my geometric parameters to optimize a design, and as you all know, COMSOL with MATLAB is the best place to do this. My problem is this, specifically:

When I 'Save as Model-M File' and open up that file in MATLAB, much to my surprise I find all my parameters to be different than what I have saved in my original COMSOL file! This is not limited to different fluid velocities at the inlet, but also inclues completely altering my geometry that I have specified in the original model.

Does anyone have any inkling as to why COMSOL is doing this? It is obviously very frustrating, and I am pretty new with the interface so I am lost as to what is happening here.

Thanks for your help!

How to output results in MATLAB livelink with COMSOL?

$
0
0
A Finite element analysis was done in COMSOL and it was saved as .m file, so that i could run it in a livelink with matlab. The program executed and i got nothing as output i.e. there were no errors but it didn't worked as a normal matlab program.
So, my problem is :
# i want the following code( this is just a line) to run and give me the output on desktop i.e. a text file.
model.result.export('plot1').set('filename', 'C:\Users\Saurav\Desktop\s.txt');

Above line was not written by me it was created when i saved my COMSOL program as a matlab file. i changed the name of text from" r.txt" to "s.txt" to see output.
Please help me regarding this topic.

Viewing all 2194 articles
Browse latest View live


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