Hi Thomas,

regarding to change
   vstepsize = max (vodeoptions.MaxStep, ...
to
   vstepsize = max (-vodeoptions.MaxStep, ...
The problem is the following: If you set MaxStep manually then it can 
only be set positive. In this case above change makes sense and solves 
an error. BUT if MaxStep is set by the solver, then it is set with the 
correct sign (i.e. positive if the ODE has to be solved forward, and 
negative it has to be solved backward). In that case the old code works 
well. So you should decide what you want to change:
Either you may allow negative MaxStep in odeset, or you have to set 
MaxStep to the absolute value if the solver set MaxStep by itself.
I would recommend to change line 187 from
     vodeoptions.MaxStep = (vslot(1,2) - vslot(1,1)) / 10;
to
     vodeoptions.MaxStep = abs(vslot(1,2) - vslot(1,1)) / 10;
I'm sorry, since it always set MaxStep manually I wasn't aware of it.

If I apply both changes even "f = ode45(@(t,y)y, [0 -1], 1) " works well.

Please let me know if it works for you as well.

Kind regards,
Nils

Am 11.06.2011 10:21, schrieb Thomas Treichl:
> Hi Nils,
>
> yes, I've further questions :) I nearly made all of your changes, but 
> if I try to solve the equation
>
>   f = ode45(@(t,y)y, [0 -1], 1)
>
> then the endpoint still is not hit exactly. So I wonder what I am 
> still doing wrong? Can you take another look at my modifiations (cf. 
> attachment).
>
> The second thing is thet with the change of line 435 from
>   vstepsize = max (vodeoptions.MaxStep, ...
> to
>   vstepsize = max (-vodeoptions.MaxStep, ...
>
> I cannot solve the equation from before at all. All the other changes 
> should be in the file...
>
> Thanks for help again
> best regards
>
>   Thomas
>
> Am 05.06.11 18:10, schrieb Nils Strunk:
>> Hi Thomas,
>>
>> ad (2): You're right. I already noticed the same and tried to fix it. 
>> I think, the best way to avoid this problem is to change line 318 from
>> vstepsize = vtimestop - vdirection * vtimestamp;
>> to
>> vstepsize = vdirection * abs(abs(vtimestop) - abs(vtimestamp));
>>
>> I didn't carefully check if it solves the problem in general, but I 
>> think it will.
>>
>>
>> I changed a few more things, that you may carry over to the official 
>> version as well:
>>
>> (1) If you solve an ODE backwards, and want to define InitialStep and 
>> MaxStep, then you'll notice that InitialStep should be negativ, 
>> whereas MaxStep couldn't be defined negative (so is supposed to be 
>> positive). On the one hand it's confusing and on the other hand this 
>> leads to problems in the algorithm. If you want to fix wrong signs in 
>> InitialStep (so, if you choose the correct sign in the definition of 
>> InitialStep doesn't matters any more), you have to replace line 272
>>     vstepsize = vodeoptions.InitialStep;
>> by
>>     if (sign(vodeoptions.InitialStep) == vdirection)
>>       vstepsize = vodeoptions.InitialStep;
>>     else %# fix wrong direction of InitialStep
>>       vstepsize = -vodeoptions.InitialStep;
>>     end
>> Furthermore (and this is really a bug!) you should change line 435
>> vstepsize = max (vodeoptions.MaxStep, ...
>> to
>> vstepsize = max (-vodeoptions.MaxStep, ...
>>
>> (2) In line 349 there is the following variable defined:
>>     vSaveVUForRefine = vu;
>> which isn't used in common. So the following if-clause will prevent 
>> to save that variable if it's not needed:
>>     if (vhaveoutputfunction && vhaverefine)
>>       vSaveVUForRefine = vu;
>>     end
>>
>> (3) Also a minor change: Add "\n" at the end of "fprintf" in lines 
>> 510-512.
>>
>>
>> If you encounter any problems with these changes, or if you have any 
>> questions regarding to this, please don't hesitate to write me.
>>
>> Kind regards,
>> Nils
>>
>>
>> Am 04.06.2011 10:23, schrieb Thomas Treichl:
>>> Hi Nils,
>>>
>>> I've taken a look at the solver problem that you've reported:
>>>
>>> (1) Looks good and I think that makes sense.
>>>
>>> (2) Does not work in general, further, if I take your example
>>>   f = ode45(@(t,y)y, [0 -1], 1)
>>>
>>> and your modified line 316 of the form
>>>   if (vdirection * (vtimestamp + vstepsize)>  vdirection * vtimestop)
>>>
>>> then the output on my machine is
>>>   error: Solving has not been successful. The iterative integration 
>>> loop exited at time t = -1.000000 before endpoint at tend = 
>>> -1.000000 was reached. This happened because the iterative 
>>> integration loop does not find a valid solution at this time stamp. 
>>> Try to reduce the value of "InitialStep" and/or "MaxStep" with the 
>>> command "odeset".
>>>
>>> Did you use any options to make that work? You're right if you say 
>>> that the endpoint is not hidden correctly! Looks like we still need 
>>> another condition. Suggestions?
>>>
>>> Best regards
>>>
>>>   Thomas
>>
>>
>


------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Octave-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to