-
-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathPMAB2Stepper.class.st
More file actions
44 lines (35 loc) · 1.43 KB
/
PMAB2Stepper.class.st
File metadata and controls
44 lines (35 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"
It is stepper for Adams - Bashforth method of order 2. We can't use AB2 method until we have two old solution values. A AB2 method is explicit. We found starting point with Midpoint Method (RK2).
"
Class {
#name : #PMAB2Stepper,
#superclass : #PMExplicitMultiStepper,
#category : #'Math-ODE'
}
{ #category : #'as yet unclassified' }
PMAB2Stepper class >> order [
"AB2 is a second order method."
^ 2
]
{ #category : #stepping }
PMAB2Stepper >> doStep: aState prevState: prevState time: t [
self stepSize isNil
ifTrue: [ self error: 'step size required by stepper' ].
^ (self stepSize / 2) * (3 * (system state: aState time: t) - (system state: prevState time: t - self stepSize)) + aState
]
{ #category : #stepping }
PMAB2Stepper >> doStep: aState prevState: prevState time: t stepSize: timeStep [
self stepSize: timeStep.
^ self doStep: aState prevState: prevState time: t .
]
{ #category : #stepping }
PMAB2Stepper >> lastStep: aState prevState: prevState time: t deltaT: incrementOfTime [
self stepSize isNil
ifTrue: [ self error: 'step size required by stepper' ].
^ self stepSize / 2 * (3 * (system state: aState time: t) - (system state: prevState time: t - incrementOfTime)) + aState
]
{ #category : #stepping }
PMAB2Stepper >> lastStep: aState prevState: prevState time: t stepSize: timeStep deltaT: incrementOfTime [
self stepSize: timeStep.
^ self lastStep: aState prevState: prevState time: t deltaT: incrementOfTime .
]