Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

mphinterp function vs. Pointwise data evaluation or export

Please login with a confirmed email address before reporting spam

Hi All,

I have got some problems about visualizing the results with Matlab. To be specific, the mphinterp function gives a very different value from the solution already stored at that point.

My code is below. Would be grateful for some insight..

THIS IS THE EXPORT FILE AND WORKS:

model.result.export.create('data1', 'Data');

model.result.export('data1').set('filename', 'D:\Users\dogan\Desktop\COMSOL_BSH_calc\Untitled.txt');

model.result.export('data1').set('gridx3', '0.145');

model.result.export('data1').set('gridy3', '2.47');

model.result.export('data1').set('gridz3', '0.1');

model.result.export('data1').set('expr', {'acpr.p_t'});

model.result.export('data1').set('location', 'grid');

model.result.export('data1').run;

THE 2ND IS THE mphinterp LINE:

SPL_rcv(iRun) = mphinterp(model,'acpr.absp','coord', [0.1447; 2.47; 0.015]);

THE 3RD OPTION IS Point EVALUATION.

model.result.numerical.create('pev1', 'EvalPoint');

model.result.numerical('pev1').selection.set([9]);

model.result.numerical('pev1').set('probetag', 'none');

model.result.numerical('pev1').setResult;

IT WORKS BUT I CANNOT SOMEHOW VISUALIZE THE VALUE AND DONT UNDERSTANT WHY THE FOLLOWING LINE GIVES ERROR:

SPL_rcv(iRun) =model.result.numerical('pev1').setResult;

Best Regards Hakan Dogan


3 Replies Last Post 25 gen 2018, 02:53 GMT-5
Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 7 years ago 24 gen 2018, 06:29 GMT-5

It can be difficult to help without seeing your model, but I have a few observations: * The expressions for the export node and mphinterp are not the same. * You fail to set an expression for the third option. * setResult doesn't return the result, but transfers it to a table (that has to be set up using the 'table' property). You probably want to use getReal and getImag instead to return the numerical result.

...but mphinterp should work. If it doesn't then please post your model (either here or send the model to support@comsol.com).

-------------------
Lars Gregersen
Comsol Denmark
It can be difficult to help without seeing your model, but I have a few observations: * The expressions for the export node and mphinterp are not the same. * You fail to set an expression for the third option. * setResult doesn't return the result, but transfers it to a table (that has to be set up using the 'table' property). You probably want to use getReal and getImag instead to return the numerical result. ...but mphinterp should work. If it doesn't then please post your model (either here or send the model to support@comsol.com).

Please login with a confirmed email address before reporting spam

Posted: 7 years ago 24 gen 2018, 07:06 GMT-5
Updated: 7 years ago 24 gen 2018, 07:07 GMT-5

Dear Lars,

Many thanks for the answer. I have noticed that the problem was with reading the complex numbers (the imaginary part of the complex number was being omitted, but with correct string format, the problem is overcome now). Otherwise, mphinterp seems working.

Thank you also for the functions getReal and getImag. They will be helpful I guess.

For interested people, I copy below how to insert a Complex Number as a boundary condition in Livelink:

presAvg=pressureInput(1,iRun);

tt=sign(imag(presAvg));

if tt==1

presStr=[num2str(real(presAvg)) '+' num2str(imag(presAvg)) 'i'];

else

presStr=[num2str(real(presAvg)) num2str(imag(presAvg)) 'i'];   

end

model.physics('acpr').feature('pr1').set('p0', presStr);

Dear Lars, Many thanks for the answer. I have noticed that the problem was with reading the complex numbers (the imaginary part of the complex number was being omitted, but with correct string format, the problem is overcome now). Otherwise, mphinterp seems working. Thank you also for the functions getReal and getImag. They will be helpful I guess. For interested people, I copy below how to insert a Complex Number as a boundary condition in Livelink: presAvg=pressureInput(1,iRun); tt=sign(imag(presAvg)); if tt==1 presStr=[num2str(real(presAvg)) '+' num2str(imag(presAvg)) 'i']; else presStr=[num2str(real(presAvg)) num2str(imag(presAvg)) 'i']; end model.physics('acpr').feature('pr1').set('p0', presStr);

Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 7 years ago 25 gen 2018, 02:53 GMT-5

Hi

I'm pretty sure that presStr = num2str(presAvg) works just as well as your slighter longer piece of code.

-------------------
Lars Gregersen
Comsol Denmark
Hi I'm pretty sure that presStr = num2str(presAvg) works just as well as your slighter longer piece of code.

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.