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

Variable modifications between solution iterations

$
0
0
I'm developing a transient model using the Livelink interface. The model first calculates an initial solution for the first time window, then I would like to modify the state variable values due to some external disturbance using MATLAB, then proceed to rerun the model for the next time window using the newly adjusted values of some of the variables, but the other variables should be retained from the previous solution iteration.

When I prescribe the use of the previous solution for subsequent iterations as:

model.sol('sol1').feature('v1').set('initmethod', 'sol');
model.sol('sol1').feature('v1').set('initsol', 'sol1');

it seems that the specification of initial conditions through either

model.variable('var15').set('X0', num2str(X0));

or

model.init('init4').set('position',num2str(X0));

are ignored completely and the unchanged values from the previous solution are retained. Is there a plausible method to effectively update some of the variables this way? Perhaps by modifying the dataset of the previous solution?

Thanks.

COMSOL 4.2a with MATLAB (COMSOL 3.5a compatibility) error

$
0
0
Hi, I'm trying to use COMSOL 4.2a with MATLAB (COMSOL 3.5a compatibility) and I obtained the following error:

Undefined variable "com" or class "com.femlab.jni.FlNativeUtil.ensureLibIsLoaded".
Error in initcomsol (line 105)
com.femlab.jni.FlNativeUtil.ensureLibIsLoaded();

And for example when I type fem.geom=circ2, this is the error:

Undefined variable "com" or class "com.femlab.util.Prop".

Can anybody help me?
Thanks.

what is wrong with the ALE

$
0
0
(all are in the .doc attachment. Thanks)

Hi,everyone,

I ‘m building a simple model based on the “heat transfer” module and the “ALE” module. The geometry is a simple rectangle. In the heat transfer node, the upper boundary is a heat flux BC, and other three are thermal insulation. In the ALE node, a prescribed normal mesh velocity is implemented on the upper boundary, other three are fixed.
Recently, I have encountered some problems relative to the ALE. Due to this reason, I deactivate the ALE module and solve the model where there is only a “heat transfer” module with some local variable to see where the error and mistake is (to ensure whether there is any wrong variable definition). In the ALE node, a “prescribed normal mesh velocity” is implemented on the upper boundary, where the ”normal mesh velocity Vn” is setting “to roeB_r+rolB_r” (m/s), After solving the model without the ALE, the theoretical normal mesh velocity (I defined a local variable with the expression of “roeB_r+rolB_r” to visualize the variable) is illustrated in the Fig. 1. In the Fig.1, we can see there should be a moving of the boundary.

(see the Fig. 1 in the attachment)

But when I activate the ALE node, the following error occurs (also as the Fig.2 shown).

Attempt to evaluate non-integral power of negative number. - Function: ^ Failed to evaluate temporary symbolic derivative variable. - Variable: mod1.rolB_r@VDN${mod1.genext1@13} - Defined as: ((1/(mod1.dB*((unit_m_cf^2)*unit_s_cf)))*((((((((log((mod1.TB/T_m))*(unit_s_cf*(mod1.DB*2)))/(r_0*unit_m_cf))^(-0.5))*0.5)*((1/(r_0*unit_m_cf))*((((((1/(mod1.dB*mod1.hcB))*(((1/(unit_K_cf*unit_m_cf))*unit_W_cf))))*2)*unit_s_cf)*log((mod1.TB/T_m)))))*unit_kg_cf)*((mod1.Pr_sB/unit_Pa_cf)^0.25))*((((unit_m_cf^3)*mod1.dB)/unit_kg_cf)^0.75))) Failed to evaluate temporary symbolic derivative variable. - Variable: mod1.ale.vn@VDN${mod1.genext1@13} - Defined as: (((1/(mod1.dB*((unit_m_cf^2)*unit_s_cf)))*((((((((log((mod1.TB/T_m))*(unit_s_cf*(mod1.DB*2)))/(r_0*unit_m_cf))^(-0.5))*0.5)*((1/(r_0*unit_m_cf))*((((((1/(mod1.dB*mod1.hcB))*(((1/(unit_K_cf*unit_m_cf))*unit_W_cf))))*2)*unit_s_cf)*log((mod1.TB/T_m)))))*unit_kg_cf)*((mod1.Pr_sB/unit_Pa_cf)^0.25))*((((unit_m_cf^3)*mod1.dB)/unit_kg_cf)^0.75)))) Failed to evaluate expression. - Expression: d(d(((mod1.ale.xt_free*mod1.ale.nx+mod1.ale.yt_free*mod1.ale.ny-mod1.ale.vn)*test(-x_lm))*(dvol),{test@0}),{mod1.genext1@13})

I’m quite puzzled about that, I can solve the model and evaluate all the relative variables without the ALE. This means there is no any wrong with the parts except the ALE section. While the above-mentioned error “fail to evaluate the relative variable” puzzles me a lot.

I have attached my .mph model, is anyone kind to check and give me some suggest?

If you wish, we can cooperate together and co-author, plz contact me.

Thanks sincerely in advance for your response.
Best wishes to you and your family.

Yours
FM Huang
Dec.22th.2011

Communication between Comsol and Matlab

$
0
0
Hello Forum,

I encounter a problem when I try to use a Matlab function within Comsol. I can plot the function in Comsol. But when I try to run the study, I receive the error attached: "Failure loading MATLAB libraries. This model requires that MATLAB is available.
I checked: "Options > Preferences > LifeLink products" There the correct path for Matlab R2011b is defined. Also in the "comsol.prefs" file the correct path is noted and the regserver is on.
The mph file and Matlab function itselfs are fine, since it is working on another machine (Win7, Comsol 4.3a, Matlab R2011b). So it must be something, unfortunately not trivial with the communication between Comsol and Matlab.

Looking forward to your replys,
Daniel Krebs

While Loops and Converge Criteria for pseudo steady state model

$
0
0
Hello,

I am attempting to create a series of simulations whose aim it is to examine the influence of my model's physics on the models geometry. What I have is a vascular geometry , which has a certain parameter (vessel diameter) which varies according to the concentration of various chemical species in my computational domain. Instead of using a transient solver I instead choose to run a series of psuedo steady state simulations. I create some sort of stimulus, a change in the consumption of one of the chemical species in the models, and this triggers a cascade of reactions which ultimately cause the diameter of the vessel to change. The convergence criteria that I wish to use is the concentration of one of the chemical species. I've tried this with average values, but would rather use the matrix of concentrations in a manner similar to how Comsol would do this. I'm trying this with the help of Matlab, but was wondering if it would be possible to only use Comsol alone and perhaps a segregated solver?

Let me know if anyone has any insight in how to deal with such a problem and perhaps tutorials which I can use in order to figure out my issues.

Thanks

Pat

Update Interpolation function in each simulation step

$
0
0
Hello Everyone,

I am trying to set up a time-dependent simulation in COMSOL v4.3a. It's a structural mechanics model and the material properties are defined by an interpolation function which is read from a txt file. However, this txt file is time-dependent as well. In other words, at (k+1)th step, I want to use the k th simulation results to update that txt file/ interpolation first. Here I have two questions.

1) I have a matlab function update_data() defined in COMSOL v4.3a. It is used to renew the txt file. However, COMSOL returns error saying "Error using dlmwirite: Could not find **.txt"
I am sure that the matlab function is correct. It seems that COMSOL doesn't support matlab to write file during simulation. Could you help me solve this issue?

2) I have to clear the interpolation function and reload from txt file manually before each time step. Are there methos that automatically clear and reload txt in interpolation function before each step?

Thank you very much

Dan

comsol with matlab

$
0
0
Hi,
I encountered a problem while using comsol. when I open the icon comsol with matlab, I got "??? Undefined variable "com" or class "com.comsol.model.util.ModelUtil.connect"."
Any ideas on what is wrong here?

Thank you in advance...

set path of the external matlab function

$
0
0
Hello all,

I am trying to run a Matlab script of my model which in turn uses an external Matlab function. When I run the model from matlab, comsol opens a new Matlab process and tries to call the function. the problem is I am not able to explicitly specify the path of the function being called.

I did add the function's path to Matlab path, but it somehow does not get updated in the new process that comsol opens internally.

Going through Java API documentation, I found that it is possible to set the path of the function using

model.func.create('extm1', 'MATLAB');
model.func('extm1').set('funcs',{<functionname>,<argslist>});
model.func('extm1').set('manpath',<path>)

This however, does not seem to work from Matlab. Any ideas, suggestions?

Also, when I copied the function in Matlab's default path (/home/user/Documents/MATLAB), the script works just fine, it only doesnt work when the path is not default

Solidworks model meshing issue

$
0
0
I created geometry of a saddle coil pair in Solidworks and then I imported it to COMSOL using the geometry import option. When I build meshes, it gives error of meshing around edges and corners.

COMSOL imports edges and surfaces. How can I import the part as a solid geometry?

I used livelink for solidworks too and got the same error.

Assign number of processors to a Comsol server

$
0
0
Hi,
the option -np sets the maximum number of processors that Comsol is allowed to use. When Comsol is started in server mode this option seems to be ignored.

For example Comsol server is started (allowing one processor only): comsol server -np 1
Then an instance of Matlab is connected to this server and a model is solved in a certain time. Now I try the same thing but allowing Comsol server to use two processors: comsol server -np 2
Solving the same model takes about the same time to finish. So -np doesn't seem to influence the runtime.

Is it possible that Comsol does not accept -np in server mode?

Best regards


[SOLVED] "Solution not initialized" when using Livelink for Matlab

$
0
0
(Documenting for others' possible benefit.)


This error happened:
============================================================
Error using com.comsol.model.impl.SolverSequenceImpl/getPVals
Java exception occurred:
Exception:
com.comsol.util.exceptions.FlException: Solution not initialized
Messages:
Solution not initialized


Stack trace:

at com.comsol.model.internal.impl.SolverSequenceImpl.ax(Unknown Source)

at com.comsol.model.internal.impl.SolverSequenceImpl.U(Unknown Source)

at com.comsol.model.internal.impl.SolverSequenceImpl.getPVals(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$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)



at com.comsol.model.clientserver.ClientManagerImpl.a(Unknown Source)

at com.comsol.model.clientserver.ClientManagerImpl.runServerJob(Unknown
Source)

at com.comsol.model.internal.impl.SolverSequenceImpl.getPVals(Unknown
Source)

at com.comsol.model.impl.SolverSequenceImpl.getPVals(Unknown Source)

Caused by: Exception:
com.comsol.util.exceptions.FlException: Solution not initialized
Messages:
Solution not initialized


at com.comsol.model.internal.impl.SolverSequenceImpl.ax(Unknown Source)

at com.comsol.model.internal.impl.SolverSequenceImpl.U(Unknown Source)

at com.comsol.model.internal.impl.SolverSequenceImpl.getPVals(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$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)


Error in C:\Programs\COMSOL43a\mli\mphsolinfo.p>mphsolinfo (line 102)


Error in process_hexes2D_v2/process_one (line 63)
info = mphsolinfo(m, 'dataset', 'dset2');

Error in process_hexes2D_v2 (line 30)
process_one(m);

============================================================



By saving as Java (after "Reset History") and comparing (gvimdiff) against an earlier version, I found that the following lines mentioning "sol2" appeared in the Java source:

...
model.batch("p1").feature("so1").set("psol", "sol2");
...
model.sol().create("sol2");
model.sol("sol2").study("std1");
...

Removing them, deleting the .run() calls and compiling as usual, everything worked normally.

The moral of the story is that if you create a solution, you'll be hit with a "Solution not initialized" error.

open .mat file in comsol

$
0
0
Hi all,

I got couple of files which are in version of 3.5a, and the file extensions are .fl and .mat.

I can open .fl through comsol, but I don't know how to open .mat in comsol, which can be opened only in matlab, but there are just several forms.

Best,

PZ

comsol default solver parameters

$
0
0
Hello all,

I am generating a matlab-script based comsol model and want to be able to run it from within Matlab. I am simulating a time-dependent study of a vibration problem.

From my understanding of comsol documentation, when I create a "time-dependent" study node, set the time parameters, the results while solving parameters and "run" the study object, comsol automatically creates a default solver object and runs the model (unless I specifically create a solver object and run it instead).

My question is is there a way to change the parameters of this default solver without me having to create a new solver object? I want to change the time-stepping method from "free" to "intermediate" or "strict" and use the rest of the default solver parameters as they are.


Thanks
Jyani

List expressions and predefined quantities in Maltab or Java

$
0
0
Hello everyone,
I'm looking for a way to find the "expressions and predefined quantities" a model offers within matlab or java.

Via COMSOL-GUI, this is simply possible by clicking one of the two buttons "Replace Expression" and "Insert Expression" within a plot - but how to get this Information within a maltab or Java application?

Any help would be great.

Thanks

Problem "To extract COMSOL data "

$
0
0
Hi
I try to follow all the steps that is mentioned in the LIVELINK FOR MATLAB USER GUIDE

"Start to load the model busbar from the COMSOL model library, enter the command:

model = mphload('busbar');

To extract the temperature and the electric potential field, use the command mpheval
as below:

dat = mpheval(model, {'T' 'V'}, 'selection', 1);

To display the temperature field enter:

mphplot(dat, 'index', 1); "

but I obtain the following error .......

??? Error: File: mphplot.p Line: 2063 Column: 0 Expression or statement is incomplete or incorrect.

I do not understand why?

I appreciate any help !!

Livelink for Matlab

$
0
0
Hi,

I would like to create a simple model using API in Matlab. When I type the command "shell.feature.create('fc1', 'FixedConstraint') ", errors "Unkonwn feature ID#FixedConstraint" exsit.

I have called for help from doucumention but found nothing. So what the "known feature ID" about the "FixedConstraint".

Many thanks for any help!

impose a local young's modulus on many subdomains

$
0
0
hi everybody
i want to make a script (matlab) to impose a local young's modulus on many subdomains (attached image of my subdomain)

someone have any idea how to make it ?


thank you very much

Coupled solutions using LiveLink

$
0
0
Hello,

I have created two models on the COMSOL server. One solves the steady-state heat equation and returns T(r,z). I can access this solution from MATLAB using mphgetu.

I'd like to feed this T(r,z), as part of the source term of a parabolic PDE (my second model). My question is, since mphgetu returns an 1XN vector where N is the number of nodes, how do I feed it back to the second model? How does the second model know what (r,z) coordinates each element of the solution vector corresponds to?

Any help will be much appreciated. Have a nice day!

-ATR

State Space Export

$
0
0
Hi ,
i have build a simple cantilever beam model using time depented model.
after defining the points of forces and parameters, i want to export the model to matlb (State Space Matrices) so i could "play" with the paramters and their location.
for example applying force at the tip = 100sin(theta(t)) and applying more forces to restrain the system.
i have searched the forum and found the mphstate function but i wasn't able to use it.

would like to get some help and tipps :)
(sorry for my poor english)

Regards, Eyal

comsol 4.2a with matlab R2011a

$
0
0
Hi,
I saved the comsol file in matlab as told. The tutorial says open ''COMSOL with MATLAB''. What does that mean?
Also i get an error as follows when i run the m file of the comsol model.

Undefined variable "ModelUtil" or class "ModelUtil.create".

Error in ==> modelmfile at 10
model = ModelUtil.create('Model');
Viewing all 2194 articles
Browse latest View live


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