How can I resolve the "Unable to solve collocation" error in MATLAB when trying to solve a nonlinear differential equation with nonlinear boundary conditions?
1 次查看(过去 30 天)
显示 更早的评论
MIT6()
%%
function MIT6
clc
close all
format long
global A B eta
A =10 ; % INTERNAL RADIUS
B=200; %% EXTERNEL RADIUS
eta = B / A; % THICKNESS RATIO
Mesh=100 ; %% MESHING
Pi = 0:0.01:2.5 %% APPLIED INNER PRESSURE
R = linspace(A, B, Mesh);
Lambda_theta = zeros(length(Pi), 1);
r_at_A = zeros(length(Pi), length(R)); %%% Specifying the size of matrix containing internal radius
for ik = 1:length(Pi)
%options = bvpset('stats', 'on', 'NMax', 50000);
solinit=bvpinit(R ,@Guess);
sol=bvp4c(@BVP_ODE,@BC,solinit)%options );
zz = deval(sol,R );
r_at_A(ik,:) = zz(1,:);
Lambda_theta(ik) = zz(1, 1) / A;
display(r_at_A)
figure(1)
hold on
plot(sol.x,sol.y(1,:),'LineWidth',3)
end
%%%%%% deformed inner radius at A
a_at_A = (r_at_A(:,1))/A;
%% GRAPHICAL PART %%%%%
figure(2)
hold on
set(gca,'FontSize',16)
plot(a_at_A,Pi,'lineWidth',3)
set(get(gca,'Ylabel'),'Rotation',0)
ylabel('$P$','Interpreter','LaTeX','FontSize',20, 'FontWeight', 'normal', 'FontName', 'Times');
% xlabel('$\Lambda_a ','Interpreter','LaTeX','FontSize',20, 'FontWeight', 'normal', 'FontName', 'Times');
xlabel('$\lambda_a$', 'Interpreter', 'latex', 'FontSize', 20, 'FontWeight', 'normal', 'FontName', 'Times');
grid on
hLegend=legend(['\eta =', num2str(eta)],'Location','SE')
% legend('boxoff')
% legend('Orientation','vertical')
set(hLegend, 'FontSize',18, 'Position', [0.7, 0.8, 0.1, 0.1]);
% Définir une boîte autour du graphe
ax = gca; % Récupérer l'objet axes actuel
set(ax, 'Box', 'on'); % Activer la boîte autour du graphe
% title('$\alpha = 5$', 'FontSize', 16, 'FontWeight', 'bold', 'Color', 'black', 'Interpreter', 'latex');
% %%
% % Add annotations
% [~, maxIndex] = max(Pi);
% text(a_at_A(maxIndex), Pi(maxIndex), 'Maximum', 'VerticalAlignment', 'bottom', 'HorizontalAlignment', 'right');
% xlabel('a/A');
% ylabel('Pi');
% title('Pi vs. a/A');
%
%
%%
% Ajouter la boîte de texte
annotation('textbox', [0.2, 0.6, 0.1, 0.1], 'String', ['Pmax : ', num2str(Pmax)],...
'FitBoxToText', 'on', 'BackgroundColor','white', 'EdgeColor', 'black','Interpreter', 'latex');
%%
% % save('pqfile.txt', 'a_at_A', '-ascii');
% Save Lambda_theta to a file (Excel format)
excelFileName = 'Lambda_theta.xlsx';
Lambda_theta_cell = num2cell(Lambda_theta);
%xlswrite(excelFileName, Lambda_theta_cell);
%% % STTING THE SYSYETME OF ODE
function dxdy = BVP_ODE(R, y)
dxdy = [y(2);
(2/3)*y(2)/R-(2/3)*(y(2)^4/y(1)^3)*R^2];
end
%%
% SETING THE BOUNDARY CONDITION
function res = BC(ya, yb)
res = [1 - A^2 / (ya(1)^2 * ya(2)^3) + Pi(ik);
1 - B^2 / (yb(1)^2 * yb(2)^3)];
end
function U = Guess(R)
U = [ 1 % Radial displacement profile
1]; % Initial guess for the second variable
% Initial guess for the second variable
end
end
7 个评论
Torsten
2024-1-3
My issue lies in the fact that the pressure curve as a function of the deformed inner radius does not decrease once it reaches its maximum value.
Looking at your solution curves, I don't know what you mean (see above).
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Numerical Integration and Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!