Linking Uqlab and Castem

Hello, I am a beginner with the Uqlab software and I want to perform the sensitivity analysis of a finite element digital model implemented in the Castem software. My problem is that I can’t make the connection between the two software I read the uqlink user manual I tried to follow the examples but I have no value. However, I was able to link my castem to MatLab with the following code and the calculation goes correctly.
n_sim = 10;
F_ct Ft.m = 3.5e6; Ft.cov = 0.13; Ft.type = 'Lognormal'; Mod_E
mod_E.m = 35e9;
mod_E.cov = 0.12;
mod_E.type = ‘Lognormal’;

Ft.data = generRV(n_sim,Ft);
mod_E.data = generRV(n_sim,mod_E);

sigma = zeros(1,n_sim);
fleche = zeros(1,n_sim);
timeCPU = 0;

for i_sim = 1 : n_sim

%% Create vector x for ith simulation
x = [ Ft.data(i_sim) mod_E.data(i_sim)];

%% Write vector x to file
fid = fopen('inputstat.txt','w');
n = max(size(x));
for i = 1:n    

%% Call Castem to calculate

dos('castem18 essais_stat_OK.dgibi');

timeCPU =   timeCPU + toc;

%% Get Output
File        =   'resultstat.out';            
A           =   textread(File,'%f');      

 fleche(i_sim) =   A(1,1);
 sigma(i_sim)  =   A(2,1);      



Here is my uqlab code.

% Model type:
ModelOpts.Type = ‘UQLink’;
ModelOpts.Name = ‘CASTEM Wrapper’;
EXECUTABLE = ‘C:\Cast3M\PCW_18\bin’;
INPUTFILE = ‘essais_stat_OK.dgibi’;

ModelOpts.Command = COMMANDLINE;

ModelOpts.Template = ‘essais_stat_OK.dgibi.tpl’;

ModelOpts.Output.FileName = ‘resultstat.out’;
ModelOpts.Output.Parser = ‘readresultOutput’;

ModelOpts.ExecutionPath = fullfile(uq_rootPath,…
‘Examples’,‘UQLink’,‘sens_stat’) ;
ModelOpts.Format = {’%1.8f’};

ModelOpts.Display = ‘quiet’;

monModelCASTEM = uq_createModel(ModelOpts);

InputOpts.Marginals(1).Name = ‘E’; Young's modulus InputOpts.Marginals(1).Type = 'Lognormal'; InputOpts.Marginals(1).Moments = [35e9 4.2e9]; (Pa)

InputOpts.Marginals(2).Name = ‘Ft’; InputOpts.Marginals(2).Type = 'Lognormal'; InputOpts.Marginals(2).Moments = [3.5e6 0.455e6]; (Pa)

myInput = uq_createInput(InputOpts);

X = uq_getSample(10,‘LHS’);

Y = uq_evalModel(monModelCASTEM,X);

Thank you in advance for your return

Hi @IHM,

It’s a bit hard to read what’s going on in your code because it is not rendered correctly.

Could you perhaps edit your post and reformat your code following the suggestion in this Markdown User Reference Guide, in particular the Code formatting section?

Thanks a lot!

PS: I move your post to the UQLab Community Q&A and How To section of UQWorld, because I think it’s more appropriate there :wink:

I found the solution to my problem just an error on the template.
Thank you

1 Like


Thanks for coming back and update this topic!