-
Filter by Topic
Most Popular
All Topics
- List all discussions
Problem with create new solution in comsol 4.1
|
Thread index | Previous thread | Next thread | Start a new discussion |
April 13, 2011 4:43pm UTC
Problem with create new solution in comsol 4.1
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??
Reply | Reply with Quote | Send private message | Report Abuse
June 28, 2011 10:29pm UTC in response to Pawel Idziak
Re: Problem with create new solution in comsol 4.1
I am also trying to do something similar, please let me know if you have figured out a solution to this. I have the same problem with COMSOL 4.1.
Reply | Reply with Quote | Send private message | Report Abuse
December 13, 2011 6:25pm UTC in response to Kevin Manktelow
Re: Problem with create new solution in comsol 4.1
Hello,
I'll put another vote in for finding a solution to this problem. Here's exactly what I'm trying to do now. I developed a model in the COMSOL GUI and solved it with success. I then saved this model as an m-file and ran it in Matlab, again with success. I saved the solution and pvals vector as variables in matlab with the:
model.sol('sol1').getU(i);
model.sol('sol1').getPVals;
commands, and cleared the model. I ran the model all the way up to the sol('sol1').runAll command, and then tried to put the values from u and pvals into the model manually and run the createSolution command. It returned the error shown above. I've tried some other things as well with these commands and haven't had success with anything. Does anybody have an answer to this?
Thanks,
-Matt
Reply | Reply with Quote | Send private message | Report Abuse
December 13, 2011 6:33pm UTC in response to Matt Cherry
Re: Problem with create new solution in comsol 4.1
Matt,
I finally had success with this. Unfortunately the only way this worked for me was in COMSOL 4.2 and 4.2a. The functionality is simply broken in 4.1. Here's a copy & paste of some notes I typed up for myself earlier. I think they should work for you.
2. Load the model in MATLAB using the command:
model = mphload('<modelname>');
3. If needed, get the size of the solution vector:
sizeVec = model.sol('sol1').getSize
u_rows = sizeVec(1);
4. Set the solution vector to some custom values:
model.sol('sol1').setU( rand(u_rows,1) )
5. Set the time value to something arbitrary (?)
model.sol('sol1').setPVals( 0 );
6. Create the solution
model.sol('sol1').createSolution
7. Obtain the mass/stiffness/load vector
MA = mphmatrix(model,'sol1','out',{'E','K','L'},'initmethod','sol')
Reply | Reply with Quote | Send private message | Report Abuse
Rules and guidelines

