how do I turn a piece of code into a parametric optimisation

3 Ansichten (letzte 30 Tage)
I have a piece of code that I would like to turn into a parametric optimisation
clear
close all
%
% Matrix properties (8552 example)
Em = 380E3; % Young's modulus
num = 0.22; % Poisson's ratio
Vv = 0.01;
KIc = 3.63; % MPa*sqrt(m) fracture toughness
% Dv = 1E-3; % void diameter
%
% Crack density parameter (from Budiansky and O'Connel, IJSS 12:81-97, 1976)
cdp0 = 0;
cdp = cdp0;
a = 0.01;
%
%%
% MECHANISMS OF CYCLIC FATIGUE-CRACK PROPAGATION IN A FINE-GRAINED ALUMINA
% CERAMIC: THE ROLE OF CRACK CLOSURE C. J. Gilbert, R. O. Ritchie 2008
C = 1.3E-18; % Paris law coefficient
m = 23; % material exponent
%
%%
% some code goes here
for k = 1:N_cycles
% some code goes here
end
I would like to change the variables Vv between 0.01, 0.38, and 0.47. I woul like to then be able to optimise a, C, and m so I can determine when these numbers give me the closest to arbitray values from literature.
Thanks
Alex

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 5 Jun. 2023
%
% Matrix properties (8552 example)
Em = 380E3; % Young's modulus
num = 0.22; % Poisson's ratio
Vv_vals = [0.01, 0.38, 0.47];
KIc = 3.63; % MPa*sqrt(m) fracture toughness
% Dv = 1E-3; % void diameter
%
% Crack density parameter (from Budiansky and O'Connel, IJSS 12:81-97, 1976)
cdp0 = 0;
cdp = cdp0;
a = 0.01;
%
%%
% MECHANISMS OF CYCLIC FATIGUE-CRACK PROPAGATION IN A FINE-GRAINED ALUMINA
% CERAMIC: THE ROLE OF CRACK CLOSURE C. J. Gilbert, R. O. Ritchie 2008
C = 1.3E-18; % Paris law coefficient
m = 23; % material exponent
%
%%
num_Vv = length(Vv_vals);
for Vv_idx = 1 : num_Vv
Vv = Vv_vals(Vv_idx);
% some code goes here
for k = 1:N_cycles
% some code goes here
end
results_per_Vv(Vv_idx) = appropriate per-Vv result
end
  2 Kommentare
A Poyser
A Poyser am 5 Jun. 2023
for the other variables will this nested loop also work?
Walter Roberson
Walter Roberson am 5 Jun. 2023
Yes. Use a vector of actual values for each of them, and calculate length of the vector, and iterate 1 to length of the vector, extract the relevant value from the full list, and use the iteration index to index where to store results.
Note: it is advisable to pre-allocate the output variables; use the recorded lengths of the vectors to size the output variables.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Quadratic Programming and Cone Programming finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by