Quantcast
Channel: Latest Discussions - COMSOL Forums
Viewing all articles
Browse latest Browse all 428

Running Comsol Desktop Model with Matlab Script: Updating Parameters

$
0
0
I am using a matlab script to update fluid parameters (viscosity and density) initially defined in comsol desktop. Based on some coupled physics, the density and viscosity of the fluid will change, once the necessary criterion is met. The flow velocity and pressure are extracted and used to determine if the criterion will be met or not, in the first place.

Now, do I need to place the "model.study('std1').run" command line after each matlab update, as schematically illustrated below:

begin code

import com.comsol.model.*
import com.comsol.model.util.*
model=mphload('XYZ');
model.study('std1').run;

% Extract Initial Pressure and Velocity based on initial prescribed parameters in comsol desktop
vf1=(mphinterp(model,'u','coord',coord1a,);
pf1=(mphinterp(model,'p','coord',coord1a);

% Given Criterion
if criterion is met
rho=rho2 (rho2 has been determined in matlab)
mu=mu2;
else if criterion is not met
rho=rho1 (rho1 is the intial fluid density)
mu=mu1;

%Updating the Parameters in Comsol
model.param.set('mu',mu)
model.param.set('rho',rho)

((model.study('std1').run; ))...xxxxxx

% Extracting the Pressure and Velocity Values
vf2=(mphinterp(model,'u','coord',coord1a,);
pf2=(mphinterp(model,'p','coord',coord1a);

% Other Calculations to be done with the second extracted pressure and velocity

end of code

Do I need to put the "xxxxx" marked line above, since I have updated the parameters, and I need to get the new pressure and velocity values? In case I erase the xxxxx line, will the extracted pressure and velocity values, (1) an (2) be different or same, considering the update on fluid properties?
In a nutshell, will the current value of the parameter in the matlab script (since the value of the parameter at latter line of the code is the current) be the current parameter in comsol desktop or do I need to rerun the comsol model with the xxxxx line command, so that I can get the corresponding flow properties based on the updated fluid properties?

Regards

Viewing all articles
Browse latest Browse all 428

Trending Articles



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