% conversion to detwinned martensite
% Material properties for the nitinol alloy used in[Dye, 1990; Liang, 1990].
% Dm modulus value for the SMA as 100% martensite in MPa
Dm = 26300;
% Da modulus value for the SMA as 100% austenite in MPa
Da = 67000;
% theta is thermal coefficeint of expansion for SMA material in MPa per degree celsius
theta = 0.55;
% Transformation Temperature
% As = austenite start temparature in degree
As = 34.5;
% Af = austenite finish temparature in degree
Af = 49;
% Ms = martensite start temparature in degree
Ms = 18.4;
% Mf = martensite finish temparature in degree
Mf = 9;
Q = (0:100:600); % Applied stress
T = 50; % Applied Temperature
aA=3.1416/(Af-As);
aM=3.1416/(Ms-Mf);
% Transformation Constants
% The constants Cm and Ca both in MPa per degree celsius, are material properties that describe the relationship of temperature and the critical stress to induce transformation,
Cm = 8;
Ca = 13.8;
% It is assumed that the critical stress values below M, to be constant and denoted by Qscr and Qfcr for the critical stresses at the start and finish of the conversion of the martensitic variants.
Qscr = 100;
Qfcr = 170;
% El is maximum residual strain
El = 0.067;
if ((Mf < T)&& (T < Ms)) && (T<To)
deltxi = (1-Xito)/2*(cos(aM*(T-Mf))+1);
else deltxi=0;
% where Xit represents the fraction of the material that is purely temperature-induced martensite with multiple variants, and Xis denotes the fraction of the material that has beentransformed by stress into a single martensitic variant.
% conversion to detwinned martensite
% initial condition
Xiso=0;
Xito=1;
Xio=0;
T=12;
if (T > Ms) && all(((Qscr + Cm*(T-Ms)) < Q) && all(Q<(Qfcr + Cm*(T-Ms))))
Xis = ((1-Xiso)/2)*cos((pi/(Qscr-Qfcr))*(Q-Qfcr-Cm*(T-Ms)))+((1+Xiso)/2);
Xit = Xito - Xito*(Xis-Xiso)/(1-Xiso) ;
end
if (T < Ms) && (all(Qscr<Q)&& all(Q< Qfcr))
Xis = ((1-Xiso)/2)*cos((pi/(Qscr-Qfcr))*(Q-Qfcr))+((1+Xiso)/2);
Xit = Xito - Xito*(Xis-Xiso)/(1-Xiso) + deltxi;
end
end
% Conversion to austenite
if (T > As) && all((Ca*(T-Af)<Q)) && all(Q <Ca*(T-As))
Xi = 1;
Xis=Xiso;
Xit=Xito;
%aA=3.1416/(Af-As);
end
% Xi has been considered to simply represent the percentage of the material transformed to martensite.
% Let Xi be further defined by
Xi = Xis + Xit;
% A reasonable assumption for the modulus function of an SMA material is
DXi = Da+Xi*(Dm-Da);
% Transformation Tensor is dedonted by omega, Q
QXi = -El*DXi;
% final constitutive equation
Qo=0; % stress induced martensite
To=24;
%Q = Qo+DXi*E-Dm+QXi*Xis-(-El*Dm)*1+ theta*(T-To);
E=(Q-Qo+Dm+QXi*Xis+(-El*Dm)*1-theta*(T-To))/DXi;
% strain is denoted by E
plot(E,Q)

1 Kommentar

Rik
Rik am 1 Jul. 2018
This is your third question. You should be able to format your own code now: select the code and hit the {}Code button.
Also, the error is self-explanatory: you are trying to use a variable before it is defined. Your current code is not readable, so I will not attempt to figure out where you made the mistake.
Have a read here (or here for more general advice) and here. It will greatly improve your chances of getting an answer.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 1 Jul. 2018

0 Stimmen

Your code is of the structure
if condition#1
deltxi = something
else
deltxi = 0
...
if condition#2
...
Xis = something
end
if condition#3
...
Xis = something
end
end
if condition#4
...
Xis = something
end
Xi = Xis + Xit;
Now, suppose that condition#1 is true, then Xis is not set (yet) and the tests for condition#2 and condition#3 are not reached (because they are in the else of condition#1). In this case, if condition#4 is false, (#1 -- true, #4 -- false) then Xis will not have been set.
Suppose condition#1 is false, then condition#2 and condition#3 are tested, but suppose they are false as well. In this case if condition#4 is false then Xis will not have been set.
So, Xis is set if #4 is true (always), or if #1 is false and #2 or #3 are true, but if #1 is true then #2 and #3 are not checked.
When we look at the structure of your code, with the same variable being set for the true and false cases of #1, it is natural for us to wonder if what you intended was a structure
if condition#1
deltxi = something;
else
deltxi = 0;
end
if condition#2
...
end
if condition#3
...
end
if condition#4
...
end
Placement of the "end" can be important.

Weitere Antworten (0)

Kategorien

Mehr zu Thermal Analysis finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by