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

Degree of freedom from extracted state space model

$
0
0
Hi all

I came to this problem. I have a simple joule heating model: an electrode sticking into a domain and flew through a current through the domain so that the mass was heated up by conductive heating effect. Then I successfully extracted the state space matrices from this model: Mc, MA, MB, C, D, (input: electrode tip voltage, output: the temperature of a point near the electrode). But, when I tried to verify the state space model (same method as introduced in the MATLAB livelink documentation, the heat_transient_axi example), I found that there's one problem that has never been discussed in the documentation: we do not know what degree of freedom or node number each state refers to, so I have no idea what initial condition to assign.

Thanks in advance for any help!

Qiyong Chen

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?

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.

Error when using Livelink for Matlab

$
0
0
Hi

I need to call a Matlab function and it works fine if i try it in the simple Matlab Command Window, but when i run the simulation and try to pass probe values to the function (I use it as objective function in the optimisation module) there is an error message: "Error in sweep. Error. Unbalanced or unexpected paranthesis or bracket."

I think it is very strange because the function works in Matlab and in the Matlab command window that Comsol opens up.

Br Rasmus

Is the LiveLink command mphint2 appropriate using the cut line dataset?

$
0
0
In Livelink application for MATLAB there is the command mphint2
using it to evaluate the results. In the evaluation of Derived Values I want to use the selection Cut Line 1 {cln1} instead of the Solution 1 {dset1} selection.

The command is
data = mphint2(model,<expr>,edim,'dataset',<dsettag>);
Can I use the selection Cut Line 1 {cln1} instead of the
Solution 1 {dset1}.

Or I must use an other command like mphglobal?

Thank you in advance

Extracting of the state space matrices

$
0
0
Hello,

I am trying to export the state space matrices of a model which I have built in COMSOL using Acoustic module. The problem is when I extract {A} and {B} matrices, I face the singular matrices but the {MA} and {MB} are evaluated without any problem.
As I have read in Livelink user guide {MA} and {MB} are eliminated mass matrix. The thing is since I have studied energy engineering my background is not that much good in vibration and dynamics, so I couldn't understand what would be the usage of {MA} and {MB} matrices in the dynamic analysis of a system. I have tried to find some relevant information in literature but couldn't find any proper explanation regarding the application of {MA} and {MB} matrices in dynamic analysis of the systems.

I would be very thankful if someone gives me some hints regarding what is the difference in term of usage between {MA} and {A} matrices.

Kind regards,
Shahin Mohammadnejad

Mass matrix is Zero

$
0
0
Hello,
I have built a model using pressure acoustic frequency domain module. I have tried to extract state space matrices using MATLAB Livelink. The problem is my mass matrix turns to null matrix. As I have read in the other discussions the problem could be related to the type of boundary conditions. My model is a simple cylindrical tube, I have specified pressure boundary condition to the inlet, sound soft boundary to the outlet and the others are sound hard boundary.
It will be great if someone gives me some hints that how can I solve my problem.

Kind regards,

Shahin Mohammadnejad

Is there an easy way to create a high number of geometric components with a random roughness component?

$
0
0
Hi all,

I am using COMSOL 4.3 to simulate a 2D photonic crystal waveguide made of air holes in a dielectric (using the emw study of the RF module), and I wish to look at how roughness around the holes (as will be inevitable from the eventual fabrication) affects the confinement of light in the waveguide. I have been wondering how to create the surface roughness, and I have come up with two solutions, neither of which are desirable:

1) Using MATLAB, I can create a script which will give the x and y coordinates for an appropriate rough circle (using the random number generator in a clever way). This can be read in to COMSOL as an interpolation curve, and there we have the first rough circle. Now, we need many circles to create the crystal. The easy way out is just to copy the one random rough circle into an array, but this is in no way good enough.

2) Same as above, but with several circles. I.e., creating several txt files from the matlab script, and importing each into an interpolation curve. Ideally this should be done for each 'circle', but it might be way to time-consuming, depending on the size of the crystal. One idea here would be to create enough 'circles', and placing them in a 'random' way, while being careful not to get any periodicity in the placement (i.e., if we have circle 1,2,3, we would not like them placed 1 1 3 2 1 1 3 2, etc...).

Probably both of these solutions are just a substitute for actual knowledge of the geometry part of the simulation tool: There must be an easier way to do this? I would suspect that it is possible to create the geometry in CAD, and importing it to COMSOL: Is there an easier way to do this with CAD software? Any other ideas?

I sincerely appreciate any help on this!

Cheers,
Marius

Edit: It would be extremely nice if there was a way which would let me redefine the roughness (i.e. the expected frequency and amplitude of the error from a perfect circle) so I can find some threshold for when the light will be guided and not... Again, I will be grateful for any help on this one...

Implement temperature variant properties using Matlab functions and Obtaining results via Comsol Livelink for Matlab during solving through parametric sweep

$
0
0
Dear All,

I have defined several properties which are temperature dependent, through user defined MATLAB functions. So as during computing the properties can be calculated in MATLAB and retrieve the solution to required points in the computation through Livelink.

I include the temperature as a parameter and performed a parametric sweep. but during computation following error occurred. I adjust the output from the MATLAB as a vector for the requirement and still I'm getting the following error.

Can you please help me with this issue

Regards
Uditha

Comsol with Matlab

$
0
0
Hello,
I saved my comsol model as a matlab file, to run it in matlab using liveLink but then I have this error.

Java exception occurred:
Exception:
com.comsol.util.exceptions.FlException: Invalid property value
(rethrown as com.comsol.util.exceptions.FlException)
(rethrown as com.comsol.util.exceptions.FlException)
Messages:
Invalid property value

Invalid property value

Invalid property value.
- Property: p

'Control points' is a matrix of real numbers.
- : Expected size is 2 × (0 – 2147483647).
- : Expected unit is: m.
- Property: p (Control points)


Stack trace:

at com.comsol.clientapi.engine.c.handleException(SourceFile:27)

at com.comsol.client.interfaces.g$d.e(SourceFile:536)

at com.comsol.client.interfaces.g.a(SourceFile:238)

at com.comsol.client.interfaces.ClientWebSocketCommandManager.a(SourceFile:464)

at com.comsol.client.interfaces.g.runAndWait(SourceFile:217)

at com.comsol.clientapi.engine.APIEngine.runMethod(SourceFile:230)

at com.comsol.clientapi.impl.GeomSequenceClient.run(SourceFile:499)

Caused by: Exception:
com.comsol.util.exceptions.FlException: Invalid property value
(rethrown as com.comsol.util.exceptions.FlException)
Messages:
Invalid property value

Invalid property value.
- Property: p

'Control points' is a matrix of real numbers.
- : Expected size is 2 (0 2147483647).
- : Expected unit is: m.
- Property: p (Control points)


at com.comsol.clientapi.engine.c.handleException(SourceFile:27)

at com.comsol.client.interfaces.g.a(SourceFile:378)

at com.comsol.client.interfaces.ClientWebSocketCommandManager.a(SourceFile:485)

at com.comsol.client.interfaces.g.processCommandAnswer(SourceFile:334)

at com.comsol.client.interfaces.g$d.e(SourceFile:534)

... 5 more

Caused by: Exception:
com.comsol.util.exceptions.FlException: Invalid property value
Messages:
Invalid property value.
- Property: p

'Control points' is a matrix of real numbers.
- : Expected size is 2 (0 2147483647).
- : Expected unit is: m.
- Property: p (Control points)


at com.comsol.nativeutil.properties.Property.k_(SourceFile:1053)

at com.comsol.nativeutil.properties.Property.d(SourceFile:1046)

at com.comsol.nativeutil.properties.v.check(SourceFile:701)

at com.comsol.nativeutil.properties.Property.getValidDoubleMatrix(SourceFile:553)

at com.comsol.model.internal.impl.PropValueImpl.getDoubleMatrix(SourceFile:747)

at com.comsol.model.internal.impl.PropFeatureImpl.O(SourceFile:2990)

at com.comsol.model.internal.impl.PropFeatureImpl.doGetDoubleMatrix(SourceFile:2907)

at com.comsol.model.internal.impl.PropFeatureImpl.getDoubleMatrix(SourceFile:1945)

at com.comsol.geommesh.geom.PrimBezierPolygon.f(SourceFile:328)

at com.comsol.geommesh.geom.PrimBezierPolygon.doExecute(SourceFile:357)

at com.comsol.geommesh.geom.s.a(SourceFile:616)

at com.comsol.geommesh.geom.s.execute(SourceFile:855)

at com.comsol.model.method.GeomFeatureMethod.build(SourceFile:860)

at com.comsol.model.method.GeomSequenceMethod.build(SourceFile:1944)

at com.comsol.model.method.GeomSequenceMethod.b(SourceFile:1827)

at com.comsol.model.method.GeomSequenceMethod.run(SourceFile:1781)

at com.comsol.model.internal.impl.GeomSequenceImpl.l(SourceFile:4124)

at com.comsol.model.internal.impl.GeomSequenceImpl$21.a(SourceFile:3277)

at com.comsol.model.internal.impl.GeomSequenceImpl$21.execute(SourceFile:1)

at com.comsol.model.clientserver.ClientManager$1.call(SourceFile:169)

at java.util.concurrent.FutureTask.run(FutureTask.java:266)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

at java.lang.Thread.run(Thread.java:745)


Error in run (line 96)
evalin('caller', [script ';']);


what is the problem !!!

Thank you
Best regards

Automatically import parameters and export simulation data

$
0
0
Hi! I'd like to do the following. I would like my Comsol model to automatically import simulation parameters (e.g. geometrical dimensions, charge density on a surface, etc.), run an auxiliary sweep and then automatically export the values of a variable for all steps of the sweep. This would be very useful, because I can run Comsol in batch mode but not Matlab.

(As an alternative, if someone can tell me how to run Matlab with Comsol on a linux machine in batch mode, I'm also happy, actually happier than with the previous solution.)

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


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