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

조회 수: 3 (최근 30일)
A Poyser
A Poyser 2023년 6월 5일
댓글: Walter Roberson 2023년 6월 5일
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

채택된 답변

Walter Roberson
Walter Roberson 2023년 6월 5일
%
% 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
A Poyser
A Poyser 2023년 6월 5일
for the other variables will this nested loop also work?
Walter Roberson
Walter Roberson 2023년 6월 5일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Quadratic Programming and Cone Programming에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by