-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add relative error check in adaptive time stepping algorithm for rk23… #275
base: 3.11
Are you sure you want to change the base?
Conversation
First of all, that you very much for the effort and for sharing this one with us. Could you please
|
* The adaptive time steeping control will benefit in cases where absolute errors of 1e-5 are much smaller than relTol * value of interest. This can help the transient simulation use larger time steps and hasten the completion of simulations.
* The fixes are directly compatible with the existing .mx3 files with no modifications needed. The limitations on my side are that I do not have the tools to perform the benchmarking that you want and I suggest you can check the differences in runtimes on your set up. Also, it is more likely that the changes will benefit simulations that typically run for a long time.
* At least 5% faster transient simulations are expected for simulations that typically take 30 minutes or longer to complete
Best,
Xuanyao (Kelvin) FONG
Assistant Professor
Department of Electrical & Computer Engineering, Faculty of Engineering
National University of Singapore
4 Engineering Drive 3
Singapore 117583
Office E4-05-23
Phone: +65-6516-6658
Fax: +65-6779-1103
Email: [email protected]
From: Mykola Dvornik <[email protected]>
Sent: Wednesday, November 18, 2020 4:17 PM
To: mumax/3 <[email protected]>
Cc: xfong <[email protected]>; Mention <[email protected]>
Subject: Re: [mumax/3] Add relative error check in adaptive time stepping algorithm for rk23… (#275)
@xfong <https://github.com/xfong>
First of all, that you very much for the effort and for sharing this one with us.
Could you please
* elaborate a bit on motivation for using relative error control;
* provide some example .mx3 scripts where it helps overcome absolute error control limitations;
* comment on what to expect performance- and precision-wise.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#275 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABRJYBLAY6QZBUSXPSDH5KLSQN7ITANCNFSM4TZTMT2Q> . <https://github.com/notifications/beacon/ABRJYBK5RPQ75RKOULPLMZTSQN7ITA5CNFSM4TZTMT22YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOFN5YICI.gif>
|
d9bf196
to
1b1eaee
Compare
|
f41d857
to
5c92e01
Compare
I need to update the code in the branch to meet your requirements.
Best,
Xuanyao (Kelvin) FONG
Assistant Professor
Department of Electrical & Computer Engineering, Faculty of Engineering
National University of Singapore
4 Engineering Drive 3
Singapore 117583
Office E4-05-23
Phone: +65-6516-6658
Fax: +65-6779-1103
Email: [email protected]
From: Mykola Dvornik <[email protected]>
Sent: Wednesday, November 18, 2020 6:26 PM
To: mumax/3 <[email protected]>
Cc: xfong <[email protected]>; Mention <[email protected]>
Subject: Re: [mumax/3] Add relative error check in adaptive time stepping algorithm for rk23… (#275)
@xfong <https://github.com/xfong>
* please be prepared for a long review process as this pull request touches very sensitive part of mumax3;
* please restructure your code in a way, that using RelErr = 0 exactly follows the current code, while RelErr > 0 triggers your modifications.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#275 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABRJYBPOI32GU5HSNCNSHNLSQOOJ5ANCNFSM4TZTMT2Q> . <https://github.com/notifications/beacon/ABRJYBNKQYRHSXPXMVBZ7IDSQOOJ5A5CNFSM4TZTMT22YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOFN6JE3A.gif>
|
5c92e01
to
c8c3e9e
Compare
c8c3e9e
to
1debc67
Compare
479e821
to
48b0c2b
Compare
…, rk45dp and rk56 time steppers
48b0c2b
to
423b316
Compare
if fail == 0 || RelErr <= 0.0 || rlerr < RelErr || Dt_si <= MinDt || FixDt != 0 { // mindt check to avoid infinite loop | ||
// step OK | ||
setLastErr(err) | ||
setMaxTorque(k2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that the value used in setMaxTorque()
is inconsistent between different solvers. [NOTE: this was already the case before this PR]
- Here in RK56 (also RK45dp and RK23),
setMaxTorque()
is set with the torques acting on the final magnetization state (i.e. thetorqueFn()
values after the finalcuda.Madd<n>(m, m0, ...)
is performed). - However, in e.g. RK4 (also Heun and Euler I think?),
setMaxTorque()
is set with the torque acting on the magnetization considered in the last stage of the RK solver (i.e. thetorqueFn()
values before the finalcuda.Madd<n>(m, m0, ...)
is performed).
Which of these two possibilities do we consider most correct?
EDIT: the reason for not calculating the final torque in RK4 etc. is that this would significantly decrease performance for simulations at nonzero temperature because then this final torque can not be re-used. Therefore, it seems that the final torque evaluation of k2
in the original RK56 code could be omitted similar to how it was done in the RK4 solver.
@@ -39,73 +50,105 @@ func (rk *RK56) Step() { | |||
h := float32(Dt_si * GammaLL) // internal time step = Dt * gammaLL | |||
|
|||
// stage 1 | |||
torqueFn(k1) | |||
torqueFn(rk.k1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to re-calculate this (at zero temperature, at least) if k2
is stored at the end of the Step
anyway.
Hi, thanks for your contribution! @xfong Could you elaborate a bit on how your code works? You claim that it can provide a >5% performance increase, but as far as I understand your code, an extra Would using a total tolerance (something like |
The AbsTol imposes a very strict check especially in steps with large changes in magnetization. The relative tolerance check allows the step to be accepted as long as the error is small relative to the change in magnetization. It is this that enables larger steps to be accepted by the steppers, which then leads to the roughly 5% faster runtimes across all the transient simulations found in the ./test directory.
|
…, rk45dp and rk56 time steppers