Популярные посты
Темы
- Цифровая обработка сигналов
- Системы управления
- Математика и статистика
- Изображения и видео
- Системы связи
- Электропривод и силовая электроника
- Робототехника и беспилотники
- ПЛИС и СнК
- Глубокое и машинное обучение(ИИ)
- Встраиваемые системы
- Автоматизация испытаний
- Верификация и валидация
- Радиолокация
- Финансы
- Другое
Популярные теги
MATLAB (305)
Simulink (201)
конкурс_hub.exponenta_2019 (55)
конкурс_hub_2021 (46)
Student_Hub_2021 (45)
Электропривод (36)
StudentHub2019 (35)
системы управления (35)
VIIВСЕРОССИЙСКАЯКОНФЕРЕНЦИЯ (30)
доклад (28)
моделирование (27)
математическое моделирование (26)
MATLAB-программирование (25)
электротехника (25)
МОП (25)
В скобках указано количество постов по тегу
Все теги
Лучший ответ
Можно выделить текст.
Нажать контрол и или контрол д, не помню точно и текст отформатируется.
И сразу станет на много легче искать где не хватает или лишенго программных блоков.
PS: А еще лучше такие длинные . . . прикреплять файлом.
//---------------------------------------------------------------------------------------------
На счет флаг тест - это да. Он у вас нигде не определен.
(Надо все используемые ф-ции иметь чтоб скрипт работал. Что-то думается ее у вас нет.)
Конкретно про флагтьест думаю этопеременная, она просто с предыдущей строчки перескочила, но там и без флаг тест дальше дофига боле не ясного.
Ну ниче, может расковыряем . . .
Ответы
Можно ведь было перевести, и тогда стало бы понятно, что отсутствует слово end, закрывающее цикл.
да потом перевели. end было НО с большой буквы потом заменив на end c маленькой ставла выходит другая ошибка
Какая ошибка?
извините за нескромность, вы можете скопировать текст прогораммы ниже к себе в матлаб и там ошибка Unrecognized function or variable 'FLAG_TEST'.
Error in Consolidation (line 13)
FLAG_TEST
будет если полсе первого цикла for добавить end
Для чего мне копировать весь огромный текст и запускать его, чтобы найти вашу ошибку? Раз вы спрашиваете, то будьте добры максимально облегчить труд тому, кто согласился вам помочь. Тем более, может, вас интересует другая ошибка, а не та, которая у меня выскочит.
Ваша ошибка появится, даже если вы совсем уберёте цикл for. Она в начале программы. У вас в отдельной строке прописана переменная (или функция) FLAG_TEST, которая заранее никак не определена, вот Матлаб и не понимает, что это такое.
clear all
clc
%% 3-D Formulation of Mohr-Coulomb and Drucker-Prager Soil Plasticity Models
% “MC_DP_Hardening_Plasticity.m”
% Primarily monotonic loading with elastic unloading option
% Drainage control option
% Strain or stress-induced loading control option
% Hardening control option
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all
% close all
global FLAG FLAG_H FLAG_HT FLAG_IHT FLAG_DRN FLAG_YF FLAG_FLOW FLAG_ETA_Y
FLAG_TEST
FLAG_TEST = '3AXI' % 3AXI: Triaxial Test, 3DIM: 3-D State
FLAG = 'MC'; % MC: Mohr-Coulomb, DP: Drucker Prager
FLAG_H = 'H'; % H: Hardening, NH: No-Hardening
FLAG_HT = 'M'; % I: Isotropic Hardening, K: Kinematic Hardening, M:Mixed Hardening
FLAG_IHT = 'NL'; % Use with (FLAG_HT=I), L: Linear
Isotropic Hardening, NL: Non-linear
Isotropic Hardening
FLAG_DRN = 'UND'; % DRN: Drained, UND: Undrained
FLAG_YF = 'SH'; % PR: Regular Prismatic MC yield surface, SH: Smoothed Hyperbolic MC yield function as in Abbo and Sloan (1995)
FLAG_FLOW = 'NONAS'; % ASSOC: Associated Flow Rule, NONAS: Nonassociated
Flow Rule
% Specified Total Strain INC. Tensors
deps_vert=0.005*ones(1,50);
N=100; % # of sub increments
L=length(deps_vert);
L=length(deps_vert);
ns=N*ones(1,L);
if FLAG_DRN == 'DRN'
for jj=1:L
eps(jj,1)=deps_vert(jj);
eps(jj,2)=0;% 0.5*deps_vert(jj);
eps(jj,3)=0;% 0.5*deps_vert(jj);
eps(jj,4)=0;
eps(jj,5)=0;
eps(jj,6)=0;
end
elseif FLAG_DRN == 'UND'
for jj=1:L
eps(jj,1)=deps_vert(jj);
eps(jj,2)=-deps_vert(jj)/2;
eps(jj,3)=-deps_vert(jj)/2;
eps(jj,4)=0;
eps(jj,5)=0;
eps(jj,6)=0;
end
end
s=size(eps);
for j=1:s(1) % Create specified sub-strain matrix
for k=1:6
deps(j,k)=eps(j,k)./ns(j);
end
end
% MATERIAL PARAMETERS
Mat_Par.G=1500; % Shear modulus
Mat_Par.K=2800; % Bulk modulus
Mat_Par.c=0; % Cohesion
Mat_Par.phi=22; % Friction angle
Mat_Par.phi_dil=18; % Dilation angle if equal to friction
angle, becomes associative
Mat_Par.Theta_T=15; % Transition Lode angle
Mat_Par.h=100; % Linear Hardening Modulus
Mat_Par.A=0.2; % Isotropic Hardening Param.
Mat_Par.S0=70; % Constant initial yield stress
Mat_Par.eta_y=0.02; % Initial hardening parameter for the size
of yield surface
Mat_Par.eta_p=1; % Limit value of the stress ratio
Mat_Par.Hp=100; % Nonlinear plastic hardening modulus
associated with the rate of expansion of
the potential/yield surface
Mat_Par.const_m=10; % Positive material parameter determined
from the tests to be used in Ziegler’s
Kin. Hard. Rule
Mat_Par.MW=0.5; % Weighting parameter -1<MW<1 to determine
what % is Kin. Hard (MW=0) and what % is Isot. Hard. (MW=1)
Scell=100; % Consolidation cell pressure
phi=Mat_Par.phi;
phi_dil=Mat_Par.phi_dil;
A=Mat_Par.A;
eta_p=Mat_Par.eta_p;
const_m=Mat_Par.const_m;
MW=Mat_Par.MW;
M=6*sin(phi*pi/180)/(3-sin(phi*pi/180)); % Critical State Stress Ratio for Triaxial Compression
Elastic_Matrix = elastic_matrix( Mat_Par ); % Call the elastic matrix
% INITIALIZATION
Stress=[Scell Scell Scell 0 0 0]; % Initial Stress State, Default: Triaxial
Compression
Total_Strain=[0 0 0 0 0 0];
Plas_Strain=[0 0 0 0 0 0];
Back_Alpha=[0 0 0 0 0 0]; % Back stress of Kinematic Hardening
Eff_Plas_Strain=0;
Pore_Pressure=0;
del_Sig_Cons=0; % Change in consolidation pressure
count=1;
Plot_Vol_Stress(count) = Scell;
FLAG_ETA_Y=0; % Flag for hardening eta_y
for j=1:s(1) % Start doing the calculations for each
element of max. total strain tensor
Stress_Inc = [0 0 0 0 0 0];
Plas_Strain_Inc = [0 0 0 0 0 0]; % Initial plastic strain inc
Strain_Inc = deps(j,:);
end
for i=1:ns(j) % For each strain increment
[I1, Shear] = components( Stress );
if FLAG == 'MC' %Mohr Coulomb
f1 = yield_func_MC( Stress, Mat_Par, Back_Alpha );
elseif FLAG == 'DP' %Drucker Prager
f1 = yield_func_DP( Stress, Mat_Par, Back_Alpha );
else
% do nothing
end
% Elastic Predictor
% Apply the Drainage Constraint
if FLAG_DRN == 'DRN'
den_el=Elastic_Matrix(2,2)+Elastic_Matrix(2,3);
Strain_Inc(3)= -Elastic_Matrix(2,1)*Strain_Inc(1)/den_el;
Mod_DE =(Elastic_Matrix(1,1)*(Elastic_Matrix(2,2)+Elastic_Matrix(2,3))-...
Elastic_Matrix(2,1)*(Elastic_Matrix(1,2)+Elastic_Matrix(1,3)) )/den_el;
Stress_Inc(1) = Mod_DE*Strain_Inc(1);
Strain_Inc(2)=Strain_Inc(3);
Stress = Stress + Stress_Inc;
elseif FLAG_DRN == 'UND'
Stress_Inc = Elastic_Matrix*Strain_Inc';
Stress = Stress + Stress_Inc';
end
[I1, Shear] = components( Stress );
[J2, J3, Theta] = invariants( Shear );
if FLAG=='MC' %Mohr Coulomb
f2 = yield_func_MC( Stress, Mat_Par, Back_Alpha );
elseif FLAG == 'DP' %Drucker Prager
f2 = yield_func_DP( Stress, Mat_Par, Back_Alpha );
else
% do nothing
End
if ( f1 < 0 && f2 <= 0 ) % If we are in elastic region
if FLAG_DRN == 'UND'
Stress = Stress - Stress_Inc'; % Back to current stress
elseif FLAG_DRN == 'DRN'
Stress = Stress - Stress_Inc;
end
Plas_Strain_Inc = [0 0 0 0 0 0];
Total_Strain_Inc = Strain_Inc;
[ del_Vol_Stress, del_Shear_Stress ] = triaxial_stress_state(Stress_Inc );
del_Pore_Pressure = del_Shear_Stress/3 - del_Vol_Stress;
elseif ( ( f1<0 || f1==0 || f1>0 ) && f2>0 ) % If we are in plastic
% region
if FLAG_DRN == 'UND'
Stress = Stress - Stress_Inc'; % Back to current stress
elseif FLAG_DRN == 'DRN'
Stress = Stress - Stress_Inc;
end
[I1, Shear] = components( Stress );
[J2, J3, Theta] = invariants( Shear );
Total_Strain_Inc = Strain_Inc;
% Calculate Gradients of F and G
dF_by_dSig=Gradient_of_Surface(Stress, phi, Mat_Par);
if FLAG_FLOW == 'ASSOC'
dG_by_dSig=dF_by_dSig;
elseif FLAG_FLOW == 'NONAS'
dG_by_dSig=Gradient_of_Surface(Stress, phi_dil, Mat_Par);
end
numer = dF_by_dSig*Elastic_Matrix;
denom = dF_by_dSig*Elastic_Matrix*dG_by_dSig';
if FLAG_H == 'H'
% Calculate the Hardening Modulus H
[ H_Mod, param_C ] = get_hardening_modulus( Stress, Mat_Par,Back_Alpha, f2 );
elseif FLAG_H == 'NH'
H_Mod = 0.0; % No ‘h’ardening, No H
else
error ‘Is Hardening Specified?’
end
% Calculate the slip rate
del_lambda = numer*Total_Strain_Inc'/(denom + H_Mod);
if del_lambda<0
display ('del_lambda < 0')
% The scalar has to be greater than zero
del_lambda=0;
else
% do nothing
end
% Calculate Plastic Strain
Plas_Strain_Inc = del_lambda*dG_by_dSig; % Non-associated flow
rule
% Calculate Stress Increment
numer = Elastic_Matrix*dG_by_dSig'*dF_by_dSig*Elastic_Matrix;
Plastic_Matrix = numer/(denom + H_Mod);
Elasto_Plastic_Matrix = Elastic_Matrix - Plastic_Matrix;
% Apply the Drainage Constraint
if FLAG_DRN == 'DRN'
den=Elasto_Plastic_Matrix(2,2)+Elasto_Plastic_Matrix(2,3);
Total_Strain_Inc(3)= -Elasto_Plastic_Matrix(2,1)*Total_Strain_Inc(1)/den;
Mod_DEP = (Elasto_Plastic_Matrix(1,1)*(Elasto_Plastic_Matrix(2,2)+Elasto_Plastic_Matrix(2,3))-...
Elasto_Plastic_Matrix(2,1)*(Elasto_Plastic_Matrix(1,2)+Elasto_Plastic_Matrix(1,3)) )/den;
Stress_Inc (1) = Mod_DEP*Total_Strain_Inc(1);
Total_Strain_Inc(2)=Total_Strain_Inc(3);
elseif FLAG_DRN == 'UND'
Stress_Inc = Elasto_Plastic_Matrix*Total_Strain_Inc';
end
% Calculate pore pressure inc.
%%%%%%%%%%%%%%% Triaxial
if FLAG_TEST == '3AXI'
[ del_Vol_Stress, del_Shear_Stress ] = triaxial_stress_state(Stress_Inc );
del_Pore_Pressure = del_Shear_Stress/3 + del_Sig_Cons -del_Vol_Stress;
elseif FLAG_TEST == '3DIM'
[del_Vol_Stress, del_Shear_Stress] = components( Stress_Inc);
del_Shear_Stress = sqrt(del_Shear_Stress(1)^2+del_Shear_Stress(2)^2+del_Shear_Stress(3)^2+...
2*del_Shear_Stress(4)^2+2*del_Shear_Stress(5)^2+2*del_Shear_Stress(6)^2 );
del_Pore_Pressure = del_Shear_Stress/3 + del_Sig_Cons -del_Vol_Stress;
end
%%%%%%%%%%%%%%% Triaxial
% Update the Hardening Parameters
if FLAG_H == 'H'
[ Back_Alpha ] = update_hardening( Plas_Strain_Inc, Stress,param_C, Mat_Par, Back_Alpha );
elseif FLAG_H == 'NH'
% do nothing
else
error ‘Is Hardening Specified?’
end
elseif ( ( f1<0 || f1==0 || f1>0 ) && f2<0 ) % Elastic Unloading
if FLAG_DRN == 'UND'
Stress = Stress - Stress_Inc'; % Back to current stress
elseif FLAG_DRN == 'DRN'
Stress = Stress - Stress_Inc;
end
Total_Strain_Inc = Strain_Inc;
% Apply the Drainage Constraint
if FLAG_DRN == 'DRN'
den=Elastic_Matrix(2,2)+Elastic_Matrix(2,3);
Total_Strain_Inc(3)= -Elastic_Matrix(2,1)*Total_Strain_Inc(1)/den;
Mod_DEP = (Elastic_Matrix(1,1)*(Elastic_Matrix(2,2)+Elastic_Matrix(2,3))-...
Elastic_Matrix(2,1)*(Elastic_Matrix(1,2)+Elastic_Matrix(1,3)))/den;
Stress_Inc (1) = Mod_DEP*Total_Strain_Inc(1);
Total_Strain_Inc(2)=Total_Strain_Inc(3);
elseif FLAG_DRN == 'UND'
Stress_Inc = Elastic_Matrix*Total_Strain_Inc';
end
Plas_Strain_Inc = [0 0 0 0 0 0];
end
if FLAG_DRN == 'UND'
Stress = Stress + Stress_Inc';
elseif FLAG_DRN == 'DRN'
Stress = Stress + Stress_Inc;
end
Pore_Pressure=Pore_Pressure+del_Pore_Pressure;
Plas_Strain = Plas_Strain + Plas_Strain_Inc;
Total_Strain = Total_Strain + Total_Strain_Inc;
count = count + 1;
Plot_Plastic_Vert_Strain(count) = abs(Plas_Strain(1));
[ Plas_Vol_Strain, Plas_Shear_Strain ] = triaxial_strain_state(Plas_Strain );
Plot_Plastic_Shear_Strain(count) = abs(Plas_Shear_Strain);
Plot_Plastic_Vol_Strain(count) = abs(Plas_Vol_Strain);
Plot_Total_Vert_Strain(count) = abs(Total_Strain(1));
[ Total_Vol_Strain, Total_Shear_Strain ] = triaxial_strain_state(Total_Strain );
Plot_Total_Shear_Strain(count) = abs(Total_Shear_Strain);
Plot_Total_Vol_Strain(count) = abs(Total_Vol_Strain);
Plot_Vert_Stress(count) = Stress(1);
[ Vol_Stress, Shear_Stress ] = triaxial_stress_state( Stress );
Plot_Shear_Stress(count) = Shear_Stress;
Plot_Vol_Stress(count) = Vol_Stress;
Plot_Pore_Pressure(count) = abs(Pore_Pressure);
end
end
% figure
subplot(2,2,1)
hold on
plot(Plot_Total_Shear_Strain,Plot_Shear_Stress,'k', 'LineWidth',2)
xlabel('Eps-q')
ylabel('q')
grid on
subplot(2,2,2)
hold on
if FLAG_DRN == 'DRN'
plot(Plot_Total_Shear_Strain,Plot_Total_Vol_Strain,'k', 'LineWidth',2)
xlabel('Eps-q')
ylabel('Eps-p')
elseif FLAG_DRN == 'UND'
plot(Plot_Total_Shear_Strain,Plot_Pore_Pressure,'k', 'LineWidth',2)
xlabel('Eps-q')
ylabel('pw')
end
grid on
subplot(2,2,3)
hold on
plot(Plot_Plastic_Shear_Strain,Plot_Shear_Stress,'k', 'LineWidth',2)
xlabel('Eps-plas-q')
ylabel('q')
grid on
subplot(2,2,4)
hold on
plot(Plot_Vol_Stress,Plot_Shear_Stress,'k', 'LineWidth',2)
xlabel('p')
ylabel('q')
grid on
%---------------------------------------------------------------
Можно выделить текст.
Нажать контрол и или контрол д, не помню точно и текст отформатируется.
И сразу станет на много легче искать где не хватает или лишенго программных блоков.
PS: А еще лучше такие длинные . . . прикреплять файлом.
//---------------------------------------------------------------------------------------------
На счет флаг тест - это да. Он у вас нигде не определен.
(Надо все используемые ф-ции иметь чтоб скрипт работал. Что-то думается ее у вас нет.)
Конкретно про флагтьест думаю этопеременная, она просто с предыдущей строчки перескочила, но там и без флаг тест дальше дофига боле не ясного.
Ну ниче, может расковыряем . . .
continue...........
А вот это точно ф-ция. У вас она есть?
PS: До выше указаной строчки явные грабли поправил. См.вложение.
UPD: читото подсказывает, что тут много что можно найти на эту тему.
elastic_matrix.m есть но выдает ошибку (см. вложение)
спасибо
смортела сначала здесь
https://www.mathworks.com/help/matlab/matlab_prog/calling-functions.html#:~:text=Undefined%20function%20or%20variable%20'x,be%20one%20of%20the%20following%3A&text=The%20function%20name%20and%20name,function%20are%20not%20the%20same
https://www.mathworks.com/matlabcentral/answers/517602-unrecognized-function-or-variable-x
программу Консолидации грунта взяла с 125 страницы этой книжки (см. вложение). там она называется Main program “MC_DP_Hardening_Plasticity.m”
внизу есть Subprogram “elastic_matrix.m”
function [ elastic_const_matrx ] = elastic_matrix( mat_par )
% Gives the 3D elastic constitutive matrix
G=mat_par.G;
K=mat_par.K;
e1=K+4*G/3;
e2=K-2*G/3;
elastic_const_matrx=[e1 e2 e2 0 0 0;
e2 e1 e2 0 0 0;
e2 e2 e1 0 0 0;
0 0 0 G 0 0;
0 0 0 0 G 0;
0 0 0 0 0 G ];
end
мне что нужно копировать и субпрогораммы? верно?
Всего по теме есть
1. Main program “Extended_MC_Plasticity.m”
2. Main program “DP_Assoc_Plas.m”
3. Main program “MC_DP_Hardening_Plasticity.m”
4. Subprogram “components.m”
5. Subprogram “yield_func_MC.m”
6. Subprogram “yield_func_DP.m”
7. Subprogram “invariants.m”
8. Subprogram “LodeAngle.m”
9. Subprogram “invariants_translated.m”
10. Subprogram “Param_DP.m”
11. Subprogram “elastic_matrix.m”
12. Subprogram “Gradient_of_Surface.m”
13. Subprogram “get_hardening_modulus.m”
14. Subprogram “triaxial_strain_state.m”
15. Subprogram “triaxial_stress_state.m”
16. Subprogram “invariant_derivative.m”
17. Subprogram “update_hardening.m”
Это вы какой-то проект откуда-то скачали?
Если так, то архивом все нужно естественно.
вот весь архив из всех main и субпрогорамм. программы с 122 страницы книги Modeling and Computing for Geotechnical Engineering An Introduction
Modeling and Computing for Geotechnical Engineering An Introduction. книжка
нужно ли указывать пути к файлам? взяла скопировала все прогораммы (частично исправила апострофы так как на апострофах матлаб выдавал ошибки) в ОДНУ папку. если мы запискаем MAIN programm к "субчикам" он сам автоматически путь находит - вель все они в одной папке?
1. Вот такая ф-ция у вас там есть. В 1-й же строчке вызывается (не важно какая) ф-ция с параметром Stress_bar, которого нет во входных параметрах. Поискал в других файлах как global переменную, тоже не находится.
Вопрос: что это? Во всех остальных строчках все, что там используется , все определено.
2. Также возвращаемый параметр I1_bar не определен.