Quantcast
Channel: LiveLink for MATLAB - Latest Discussions - COMSOL Forums
Viewing all 99 articles
Browse latest View live

Exporting Load functions applied in COMSOL to MATLAB

$
0
0
I want to export the edge load function data I applied in SOLID MECHANICS physics to MATLAB.

I found the name as "solid.FperLengthy".

When I try to extract data with help of "mpheval(model,'solid.FperLengthy')"; MATLAB doesn't recognize the variable and giving me error as undefined variable.

Would anyone please help me in this? How can I extract the data from physics to the MATLAB??

Thanks in advance.

integrating a scalar field in one direction

$
0
0
The model that i am working on contains a plate that is locally heated. the temperature field is thus non-uniform over the whole domain. What i want is the average temperature in the Z direction perpendicular on the plate. Thus a temperature plane with the weighted average temperature in Z direction.

How can i accomplish this?
I played around with the derived values but nothing is satisfactory. the volume average gives the average temperature of the plate (scalar).

Advanced Closed-Loop Control of COMSOL Model using Matlab

$
0
0
Hi

I'm an experienced user of Matlab where I usually do modelling and simulation of a desired control object. The problem is, that the object I'm about to control contains some complicated dynamics, that would be tedious to model and simulate in Matlab.

Instead, I would like to simulate the model in a more appropriate software like COMSOL, while calculating the control action from Matlab. In this way, I can take advantage of all the control-toolboxes available in Matlab, while using the modeling and simulation engine of COMSOL. I have never used COMSOL, but it seems to be a very powerful tool.

In a quick search I encountered LiveLink™ for MATLAB. Do anyone know if that can be used to create the link between Matlab and COMSOL that I'm looking for?

Best Regards,
Andreas

COMSOL with MATLAB

$
0
0
Hi, does anybody know how to change the length unit of a geometry in MATLAB, i.e set um or nm on the MATLAB script in order to set the desired length unit in the model geometry in COMSOL

Errors in COMSOL with Matlab

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

COMSOL - MatLab combination without LiveLink( for MatLab)

$
0
0
Hi,
I use a class kit license COMSOL version which doesn't include the livelink for MatLab.
However I want to run a loop in MatLab using some COMSOL outputs.
Specifically I want to write a MatLab code that makes some iterations. The MatLab code includes a set of data.
COMSOL reads these data as inputs and then returns some outputs.
I compare these outputs with the reference values,
and if the difference diverges from zero then I change the input values and I rerun the
COMSOL. I repeat this loop as long as the difference is much bigger than zero

I would like to find a way to obtain this without using LiveLink for MatLab, but I got stuck.
Is there any idea?

Thank you in advance.
PD

Can I extract the algorithm that corresponds to the COMSOL solution?

$
0
0
Hi!
I would like to extract the code of a COMSOL file so that I can interfere when ever I want,
How can I do that? Is there any idea?

Thank you in advance!

PD

How to re-order two different solutions (Livelink MATLAB)

$
0
0
There are two ways to get a vector of solution data, I know.

1. Using "getU" and index. That is:
temp1 = model.sol(<soltag>).getU;
data1 = temp(index);

2. Using the function, "mpheval" directly. That is:
temp2 = mpheval(model,<expr>, 'smooth', 'none', 'pattern', 'gauss');
data2 = temp2.d1';

Both way, I can get a vector of solution data I need, but they are different in order.

I've used "getU" to get data, because I have to use "setU" later.
However I need another data evaluated by "mpheval" to filter the data above.

How can I match these two each other?

How to access eigenvalues in Matlab Live Link?

$
0
0
Hello,
I would like to access the eigenvalues from the comsol solver (Eigenvalue solver) in Matlab Live Link. I use Comsol v 5.2

so far I can load the model and run the solver in Matlab:

modelName='paramSweep.mph';
model = mphload(modelName);
model.sol('sol1').clearSolution();
model.study('std1').run;

now I need somehow to get the eigenvalues...

charge particle tracing link with matlab

$
0
0
In charge particle tracing, I use 'release from data file' to release particles. Now I want to use matlab to change the data file. Seem it changed from the comsol desktop. It looked same as before. But an error occur when running the study.

Failed to load file for initial particle positions.
- File
Error in multiphysics compilation.


I have tried when setting in comsol desktop. Study can run normally. It's so confusing.

stiffness matrix

$
0
0
hello,

maybe thats a stupid question. How can I see the stiffness matrix my solver is working with.

I know the matrix has a high dimension so I can't really look at it. But is it possible to see some "statistics", like symmetry, entries unequel 0 etc.?

I'm using Comsol 4.2

Thanks

LiveLink for MATLAB Y Axis Label Mirroring Problem in Mac OS X

$
0
0
When plotting a figure with the LiveLink for MATLAB, the Y label appears as a mirror image. I am running COMSOL 4.3a (4.3.1.161) with 64-bit Matlab R2012b (8.0.0.783) in Mac OS X Version 10.8.3. The problem does not occur if I make the plot directly in Matlab, so I believe it must be a bug in the LiveLink. Has anyone else experienced this problem or know if it is a known bug or have any workarounds? Any help would be appreciated - thank you. Code for the figure pasted below.

% Create figure for permeability dispersion
figure3 = figure('Color',[1 1 1],'Position',[1 51 640 450],'PaperPositionMode','Auto','Visible','on');

% Create axes
axes('Parent',figure3,...
'YGrid','on',...
'XLim',[min(lambda_0)*1e9 max(lambda_0)*1e9],...
'XMinorTick','on',...
'XGrid','on',...
'LineWidth',3,...
'FontWeight','bold',...
'FontSize',18,...
'FontName','Times');
box('on');
hold('all');

% Create real part of simulated plot
plot(lambda_0.*1e9,real(mu_sim),'MarkerSize',20,'Marker','.','LineStyle','-','LineWidth',2,'Color',[1 0 0]);

% Create imag part of simulated plot
plot(lambda_0.*1e9,imag(mu_sim),'MarkerSize',20,'Marker','.','LineStyle','-','LineWidth',2,'Color',[0 0 1]);

% Create xlabel
xlabel('Wavelength [nm]','FontWeight','bold','FontSize',18,...
'FontName','Times');

% Create ylabel
ylabel('Relative Permeability (\mu)','FontWeight','bold','FontSize',18,...
'FontName','Times');

% Create legend
legend('{\mu}_{real} (COMSOL)','{\mu}_{imag} (COMSOL)','location','Best');

"Java exception" problem during multiple iterations in Livelink for MATLAB

$
0
0
Hi everyone, this forum is great and it helped a lot to grow in COMSOL world.

Anyway, now i am trying to calculate/simulate a phase growth process considering the mass transfer through the interfaces, in which I am using "Livelink for MATLAB' module.
For each iteration, the solution from the previous study was passed down as intial values for the current step and some boundary conditions were changed also. The original plans are to repeat about 10000 iterations, while MATLAB always jumped out after about 2600 iterations with this red "Java exception" warnings. I tried to change the settings in COMSOL and MATLAB wherever shows "cache size" or "buffer size" but it is still happening at exact the same point.

So could you guys help me out with it? Really appreicate your effort and help!!!

ps: I paste the MATLAB warning here. If you want to see the M file, i would upload it later.

Java exception occurred:
Exception:
com.comsol.util.exceptions.FlException: The following feature has encountered a problem
(rethrown as com.comsol.util.exceptions.FlException)
(rethrown as com.comsol.util.exceptions.FlException)
Messages:
The following feature has encountered a problem
The following feature has encountered a problem
The following feature has encountered a problem:
Error in multiphysics compilation.
- Feature: Compile Equations: Time Dependent (sol5158/st1)
Stack trace:
at com.comsol.clientapi.engine.c.handleException(Unknown Source)
at com.comsol.client.interfaces.f$d.f(Unknown Source)
at com.comsol.client.interfaces.f.a(Unknown Source)
at com.comsol.client.interfaces.f.runAndWait(Unknown Source)
at com.comsol.clientapi.engine.APIEngine.runMethod(Unknown Source)
at com.comsol.clientapi.engine.APIEngine.runMethod(Unknown Source)
at com.comsol.clientapi.impl.SolverSequenceClient.runAll(Unknown Source)
Caused by: Exception:
com.comsol.util.exceptions.FlException: The following feature has encountered a problem
(rethrown as com.comsol.util.exceptions.FlException)
Messages:
The following feature has encountered a problem
The following feature has encountered a problem:
Error in multiphysics compilation.
- Feature: Compile Equations: Time Dependent (sol5158/st1)
at com.comsol.clientapi.engine.c.handleException(Unknown Source)
at com.comsol.client.interfaces.f.a(Unknown Source)
at com.comsol.client.interfaces.f.processCommandAnswer(Unknown Source)
... 6 more
Caused by: Exception:
com.comsol.util.exceptions.FlException: The following feature has encountered a problem
Messages:
The following feature has encountered a problem:
Error in multiphysics compilation.
- Feature: Compile Equations: Time Dependent (sol5158/st1)
at com.comsol.solver.SolverOperation.addError(Unknown Source)
at com.comsol.solver.SolverOperation.execute(Unknown Source)
at com.comsol.model.internal.impl.SolverSequenceImpl.a(Unknown Source)
at com.comsol.model.internal.impl.SolverSequenceImpl.i(Unknown Source)
at com.comsol.model.internal.impl.SolverSequenceImpl$23.a(Unknown Source)
at com.comsol.model.internal.impl.SolverSequenceImpl$23.execute(Unknown Source)
at com.comsol.model.clientserver.ClientManager$1.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)

mphplot: multiple legends

$
0
0
At the mphplot voice of the online documentation:
Only one color range bar and one legend bar is supported in a MATLAB figure. When the option plot on server is active, all active color range bar are displayed.

That's very disappointing. I actually have a surface plot and a countour plot in the same figure and I want to see the scales for both.
I don't really understand the second sentence: When the option plot on server is active, all active color range bar are displayed. But activating the plot on server option does not help (maybe I should explore it a bit more, but I don't see what is it doing).

(I actually also have an arrow plot, but I believe there is no legend in comsol for the arrow plots, right?)

How to determine domain number from a given block name.

$
0
0
Hi
I'm currently working with a project where I have to prepare a model to be illuminated in the RF module by microwawes and ultimately being able to determine the location of tumors in human tissue.

This model requires, among many other things, that the model of the illuminated medium can be altered between to different types of materials, essentially flesh and something other than flesh, water is used so far for convenience. All of this model is intended to be controllede via the LiveLink interface to COMSOL and the illuminated medium is created using matlab commands, given a 10x10x10 grid of squares where it was my intend that the changes in medium could be done simply by selecting between to materials, using the command:

>> model.material('mat2').selection(*insert numbers here*);

but in order to do so, I need the domain numbers of a given block, and clicking them manually is not an option, as the full solution should be capable of handling in excess of 10000 block.

Each block has been created with code below, in order to ease identification:

%Array creation
for x=1:10;
for y = 1:1;
for z = 1:1;
CellSize = 5;
s = strcat('blk_x',num2str(x),'_y',num2str(y),'_z',num2str(z));
model.geom('geom1').feature.create(s, 'Block');
model.geom('geom1').feature(s).setIndex('size', num2str(CellSize), 0);
model.geom('geom1').feature(s).setIndex('size', num2str(CellSize), 1);
model.geom('geom1').feature(s).setIndex('size', num2str(CellSize), 2);
model.geom('geom1').feature(s).setIndex('pos', num2str(CellSize*x), 0);
model.geom('geom1').feature(s).setIndex('pos', num2str(CellSize*y), 1);
model.geom('geom1').feature(s).setIndex('pos', num2str(CellSize*z), 2);
end
end
end

The name string is for example 'blk_x10_y1_z1'

Have a nice weekend. -Thomas

MATLAB LiveLink: Combine different contours

$
0
0
Hi,
I was wondering what the best way is to create a geometry that combines contours. For example, I have a geometry that is made up of various domains. When I use the commands

figure(1); [c,h] = contourf(p); clabel(c, h); colorbar;

then the relevant contours I need are for example the ones with values 150 and 250. mphimage2geom however only let's me use one of those values. How can I get the whole geometry into one .mph file? I've attached the image I'm trying to model in case I'm using the wrong approach entirely. White is the background, grey and black are two different types of domain.

Thanks!
Alexandra

Exporting a geometry file (parasolid_binary) using MATLAB Livelink

$
0
0
Hello,

I would like to export a geometry from COMSOL in parasolid_binary using MATLAB live link ?

You can easily do this from COMSOL desktop, however, I could not do it using the Live link.

Please, provide me the syntax

Thank you in advance

How can I use matlab console and comsol desktop at the same time?

$
0
0
When I run `comsol server matlab`, there is only a matlab console popped out. If I want to see what my matlab scripts done, I have to use mphplot to plot them. It takes time to write the mphplot script, so it is not very convenient for script debugging.

Therefore, I want to know if there is anyway to view the model change or calculation results in a comsol desktop window as soon as the matlab scripts run?

Thanks

mphgeom in matlab uipanel

$
0
0
Hi, I'm building a little user interface with Matlab 14, using the LiveLink for COMSOL v.5. The interface is composed of different panels and I would like to plot the COMSOL model geometry on an axis object placed on one of these panels by using mphgeom command.
I get an error that says "panel object does not have a valid renderer". Any suggestion or workarounds? I tried changing the default renderer from OpenGL to painter but it didn't work.
Thank you!
Michele

Adding MATLAB Livelink to COMSOL

$
0
0
Hey all!
I am trying to link MATLAB with COMSOL 4.4, Is there anyone who knows how to activate Livelink for MATLAB in it? It seems that while installing COMSOL I did not give the path of the MATLAB hence I am not able to use it. Please help me in this regard as early as possible.

Thanks
Viewing all 99 articles
Browse latest View live


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