how do I turn a piece of code into a parametric optimisation
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
A Poyser
el 5 de Jun. de 2023
Comentada: Walter Roberson
el 5 de Jun. de 2023
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
0 comentarios
Respuesta aceptada
Walter Roberson
el 5 de Jun. de 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 comentarios
Walter Roberson
el 5 de Jun. de 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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Quadratic Programming and Cone Programming en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!