"Unable to Meet Integration Tolerances"

2 vues (au cours des 30 derniers jours)
Tom Keaton
Tom Keaton le 20 Sep 2019
Modifié(e) : Tom Keaton le 20 Sep 2019
I am receiving the following error:
Warning: Failure at t=7.032410e-09. Unable to meet integration tolerances without reducing the step size below the smallest value
allowed (1.323489e-23) at time t.
> In ode15s (line 730)
In collisions7 (line 215)
Unable to perform assignment because the size of the left side is 3-by-6 and the size of the right side is 2-by-6.
Error in collisions7 (line 216)
Wposandvel(p).matrix((1+2*t):(3+2*t),(1:6)) = S; %Send solution vector to data structure
The odd part is that the error only occurs when I add this to one of the equations:
con*(s(3).^3)
Where "con" is defined in the following script and the added function is shown here (All of the equations are purposefully defined on a single line because when I gave them each their own assignments then redefined the vector that way as the documentation does in its examples, the solver does not produce correct answers at all):
function bdip = bdipuniodefun(t,s)
%Using SI units
q = -1.60217662E-19;
m_e = 9.11E-31;
%con = -2.5E+8;
persistent Bx By Bz
if isempty(Bx)
[Bx, By, Bz] = B_test();
end
bdip = [s(4); s(5); s(6); (q/m_e)*(s(5)*Bz(s(1),s(2),s(3)) - s(6)*By(s(1),s(2),s(3))); -(q/m_e)*(s(6)*Bx(s(1),s(2),s(3)) - s(4)*Bz(s(1),s(2),s(3))); (q/m_e)*(con*(s(3).^3) + s(4)*By(s(1),s(2),s(3)) - s(5)*Bx(s(1),s(2),s(3)))];
end
"B_test" function file:
function [Bx, By, Bz] = B_test()
Bfieldstrength = 0.64; %In (Teslas)
magvol = 3.218E-6; %In (m)
mu0 = (4*pi)*10^-7;
magnetization = (Bfieldstrength*magvol)/mu0;
syms x y z
m = [0,0,magnetization];
r = [x, y, z];
B = mu0*(((dot(m,r)*r*3)/norm(r)^5) - m/norm(r)^3);
Bx = matlabFunction(B(1));
By = matlabFunction(B(2));
Bz = matlabFunction(B(3));
end
If that little piece of the function is not added, the ODE solver runs just fine. I feel that this should not be throwing an error because solving these equations are fairly trivial so I don't understand how the minimum "tolerances" are violated. What can I do to alleviate this error? I attached the main code also that calls this but view at your own discretion as it is around 400 lines (collisions7).

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by