diff --git a/ConfigurationOfSciSmalltalk.package/ConfigurationOfSciSmalltalk.class/instance/version203..st b/ConfigurationOfSciSmalltalk.package/ConfigurationOfSciSmalltalk.class/instance/version203..st index b051239..68bf56c 100644 --- a/ConfigurationOfSciSmalltalk.package/ConfigurationOfSciSmalltalk.class/instance/version203..st +++ b/ConfigurationOfSciSmalltalk.package/ConfigurationOfSciSmalltalk.class/instance/version203..st @@ -6,13 +6,14 @@ version203: spec spec blessing: #'development'. spec description: 'modified Random tests and fixed an error in MTGenerator relaxed convergence bound on PoissonGenerator -added announcements/watchers to ODESolver '. +added announcements/watchers to ODESolver +changes to Math-ODE'. spec author: 'DanielUber'. - spec timestamp: '6/8/2012 11:43'. + spec timestamp: '6/10/2012 10:52'. spec package: 'Math-Random' with: 'Math-Random-DanielUber.6'; package: 'Math-KDTree' with: 'Math-KDTree-wernerkassens.6'; - package: 'Math-ODE' with: 'Math-ODE-DanielUber.11'; + package: 'Math-ODE' with: 'Math-ODE-DanielUber.12'; package: 'Math-Complex' with: 'Math-Complex-DanielUber.6'; package: 'Math-Quaternion' with: 'Math-Quaternion-DanielUber.5'; package: 'Math-DHB-Numerical' with: 'Math-DHB-Numerical-DanielUber.20'; diff --git a/ConfigurationOfSciSmalltalk.package/monticello.meta/version b/ConfigurationOfSciSmalltalk.package/monticello.meta/version index 7a5a3e0..31d3a9c 100644 --- a/ConfigurationOfSciSmalltalk.package/monticello.meta/version +++ b/ConfigurationOfSciSmalltalk.package/monticello.meta/version @@ -1 +1 @@ -(name 'ConfigurationOfSciSmalltalk-DanielUber.24' message 'added announcements/watchers to ODESolver ' id '7e0b4886-52a9-4491-b929-f7641c5670d9' date '8 June 2012' time '11:43:57.51 am' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.23' message 'relaxed convergence bound on PoissonGenerator' id '747d7c2f-457a-4132-a957-33750cff5d47' date '7 June 2012' time '2:27:51.162 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.22' message 'modified Random tests and fixed an error in MTGenerator' id '0f45fdc1-0c58-4010-a30e-50f0130ca821' date '7 June 2012' time '2:08:52.142 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.21' message 'added development version' id 'b6d83195-55f7-40ff-8b10-5f232f1761a1' date '6 June 2012' time '12:01:21.914 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.20' message 'made 1-03 stable' id '60e30bf9-2e99-46cf-95d6-60c606751abf' date '6 June 2012' time '11:49:17.017 am' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.19' message 'fixed version 1-03' id '805189c6-d9db-4f4e-8a91-625b86bddbb4' date '6 June 2012' time '11:43:44.484 am' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.18' message 'version 1.03 using new Random and RandomTests packages. Testing automatic version generation using MetacelloToolbox.' id '0958cbf7-a326-44ce-96ce-d711aaf153a6' date '6 June 2012' time '11:01:46.953 am' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.17' message 'changed bleedingEdge to use development.' id '082f9c55-8dcc-4e25-a860-06bf37cc7774' date '6 June 2012' time '10:58:05.406 am' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.16' message 'changed version 1.02 to reflect new Complex, Quaternion, and Numerical package numbers.' id 'f8b5a5fe-dec3-4e50-8a28-83d6de695fd7' date '5 June 2012' time '5:03:59.538 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.15' message 'updated package names after renaming extensions packages for Quaternion, Numerical, and Complex.' id '0cd8165d-d9e9-4364-8962-5bab5cb8d9a9' date '5 June 2012' time '4:57:50.098 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.14' message 'changed load order.' id '0b8e97a6-643c-439f-a5a9-105967bd3462' date '5 June 2012' time '4:27:20.258 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.13' message 'separated package load. ' id 'a9546148-d07f-465c-9f30-753f18440cdd' date '5 June 2012' time '3:39:42.348 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.12' message 'corrected typo in bleedingEdge.' id '7f0f99d3-5579-45f3-b07c-b3a6eccdb21f' date '20 May 2012' time '2:47:13.668 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.11' message 'added bleedingEdge version and updated to version 1.01' id '7e959693-c85b-4404-96d3-6e6cde48cb78' date '20 May 2012' time '2:44:26.266 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.10' message 'modified to try to load Math-All from ss3.' id '58c70684-ae18-470a-95cc-a4d4210e951b' date '17 May 2012' time '2:19:41.766 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.9' message 'currently loading DHB-Numerical, then Complex. There is an issue where DHB-Numerical needs Complex and Quaternion due to extensions, and Complex needs DHB-Numerical due to extensions. This may take some rethinking of the package structure (or require an extensions package).' id '9f772bde-a2f4-4d3a-9902-366cb0feeaf2' date '16 May 2012' time '4:11:19.556 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.8' message 'fixed typo in baseline.' id '384b19df-693f-4625-8399-bb2d83b68f14' date '16 May 2012' time '3:52:32.332 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.7' message 'added DHB-Numerical and fixed typos. Added to default and tests.' id 'b22b3ea1-6136-4ad2-ad87-b39fcfe6fb21' date '16 May 2012' time '3:50:26.232 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.6' message 'added DHB-Numerics as a dependency for Math-Complex.' id '2eb9c399-f1a4-4d7f-893d-48d06fc55424' date '16 May 2012' time '3:45:29.334 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.5' message 'added development version' id '0af623af-81f0-47ba-89e0-cc51698b2e9c' date '16 May 2012' time '3:35:20.434 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.4' message 'fixed dependency in baseline from Example-Core to Math-Complex.' id '7c5f16b4-3bfe-43bf-8ff6-33a9682d6f73' date '16 May 2012' time '3:28:34.716 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.3' message 'added version 100' id '3aae054c-4bc9-42e2-972c-dd44b5a1c722' date '16 May 2012' time '3:26:12.942 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.2' message 'created baseline for complex.' id '0c94552e-1fa2-437f-a308-71a3b71ab8dd' date '16 May 2012' time '3:21:19.742 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.1' message 'empty configuration. First commit.' id '2b16cd0b-9384-4fe9-a139-62c2f1fb7e84' date '16 May 2012' time '2:04:26.726 pm' author 'DanielUber' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file +(name 'ConfigurationOfSciSmalltalk-DanielUber.25' message 'changes to Math-ODE' id '8d70780a-18de-4879-b23c-da270de0f4ec' date '10 June 2012' time '10:52:19.332 am' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.24' message 'added announcements/watchers to ODESolver ' id '7e0b4886-52a9-4491-b929-f7641c5670d9' date '8 June 2012' time '11:43:57.51 am' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.23' message 'relaxed convergence bound on PoissonGenerator' id '747d7c2f-457a-4132-a957-33750cff5d47' date '7 June 2012' time '2:27:51.162 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.22' message 'modified Random tests and fixed an error in MTGenerator' id '0f45fdc1-0c58-4010-a30e-50f0130ca821' date '7 June 2012' time '2:08:52.142 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.21' message 'added development version' id 'b6d83195-55f7-40ff-8b10-5f232f1761a1' date '6 June 2012' time '12:01:21.914 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.20' message 'made 1-03 stable' id '60e30bf9-2e99-46cf-95d6-60c606751abf' date '6 June 2012' time '11:49:17.017 am' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.19' message 'fixed version 1-03' id '805189c6-d9db-4f4e-8a91-625b86bddbb4' date '6 June 2012' time '11:43:44.484 am' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.18' message 'version 1.03 using new Random and RandomTests packages. Testing automatic version generation using MetacelloToolbox.' id '0958cbf7-a326-44ce-96ce-d711aaf153a6' date '6 June 2012' time '11:01:46.953 am' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.17' message 'changed bleedingEdge to use development.' id '082f9c55-8dcc-4e25-a860-06bf37cc7774' date '6 June 2012' time '10:58:05.406 am' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.16' message 'changed version 1.02 to reflect new Complex, Quaternion, and Numerical package numbers.' id 'f8b5a5fe-dec3-4e50-8a28-83d6de695fd7' date '5 June 2012' time '5:03:59.538 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.15' message 'updated package names after renaming extensions packages for Quaternion, Numerical, and Complex.' id '0cd8165d-d9e9-4364-8962-5bab5cb8d9a9' date '5 June 2012' time '4:57:50.098 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.14' message 'changed load order.' id '0b8e97a6-643c-439f-a5a9-105967bd3462' date '5 June 2012' time '4:27:20.258 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.13' message 'separated package load. ' id 'a9546148-d07f-465c-9f30-753f18440cdd' date '5 June 2012' time '3:39:42.348 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.12' message 'corrected typo in bleedingEdge.' id '7f0f99d3-5579-45f3-b07c-b3a6eccdb21f' date '20 May 2012' time '2:47:13.668 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.11' message 'added bleedingEdge version and updated to version 1.01' id '7e959693-c85b-4404-96d3-6e6cde48cb78' date '20 May 2012' time '2:44:26.266 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.10' message 'modified to try to load Math-All from ss3.' id '58c70684-ae18-470a-95cc-a4d4210e951b' date '17 May 2012' time '2:19:41.766 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.9' message 'currently loading DHB-Numerical, then Complex. There is an issue where DHB-Numerical needs Complex and Quaternion due to extensions, and Complex needs DHB-Numerical due to extensions. This may take some rethinking of the package structure (or require an extensions package).' id '9f772bde-a2f4-4d3a-9902-366cb0feeaf2' date '16 May 2012' time '4:11:19.556 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.8' message 'fixed typo in baseline.' id '384b19df-693f-4625-8399-bb2d83b68f14' date '16 May 2012' time '3:52:32.332 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.7' message 'added DHB-Numerical and fixed typos. Added to default and tests.' id 'b22b3ea1-6136-4ad2-ad87-b39fcfe6fb21' date '16 May 2012' time '3:50:26.232 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.6' message 'added DHB-Numerics as a dependency for Math-Complex.' id '2eb9c399-f1a4-4d7f-893d-48d06fc55424' date '16 May 2012' time '3:45:29.334 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.5' message 'added development version' id '0af623af-81f0-47ba-89e0-cc51698b2e9c' date '16 May 2012' time '3:35:20.434 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.4' message 'fixed dependency in baseline from Example-Core to Math-Complex.' id '7c5f16b4-3bfe-43bf-8ff6-33a9682d6f73' date '16 May 2012' time '3:28:34.716 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.3' message 'added version 100' id '3aae054c-4bc9-42e2-972c-dd44b5a1c722' date '16 May 2012' time '3:26:12.942 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.2' message 'created baseline for complex.' id '0c94552e-1fa2-437f-a308-71a3b71ab8dd' date '16 May 2012' time '3:21:19.742 pm' author 'DanielUber' ancestors ((name 'ConfigurationOfSciSmalltalk-DanielUber.1' message 'empty configuration. First commit.' id '2b16cd0b-9384-4fe9-a139-62c2f1fb7e84' date '16 May 2012' time '2:04:26.726 pm' author 'DanielUber' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file diff --git a/Math-ODE.package/ExplicitSolverSubscriber.class/README.md b/Math-ODE.package/ExplicitSolverSubscriber.class/README.md index e69de29..9b0ac7d 100644 --- a/Math-ODE.package/ExplicitSolverSubscriber.class/README.md +++ b/Math-ODE.package/ExplicitSolverSubscriber.class/README.md @@ -0,0 +1 @@ +An ExplicitSolverSubscriber implements the minimal behavior to attach to an ODESolver and receive ExplicitSolverAnnouncements. Subclasses should override block to determine appropriate behavior. diff --git a/Math-ODE.package/ExplicitSolverSubscriber.class/properties.json b/Math-ODE.package/ExplicitSolverSubscriber.class/properties.json index 9a931a6..7a71a90 100644 --- a/Math-ODE.package/ExplicitSolverSubscriber.class/properties.json +++ b/Math-ODE.package/ExplicitSolverSubscriber.class/properties.json @@ -5,7 +5,7 @@ "classtraitcomposition" : "{}", "classvars" : [ ], - "commentStamp" : "", + "commentStamp" : "", "instvars" : [ "announcers", "block" ], diff --git a/Math-ODE.package/ODESolver.class/instance/announceState.time..st b/Math-ODE.package/ODESolver.class/instance/announceState.time..st new file mode 100644 index 0000000..4d36b9f --- /dev/null +++ b/Math-ODE.package/ODESolver.class/instance/announceState.time..st @@ -0,0 +1,3 @@ +accessing +announceState: aState time: aTime + self announcer announce: (ExplicitSolverAnnouncement x: aState t: aTime). \ No newline at end of file diff --git a/Math-ODE.package/ODESolver.class/instance/lastStepState.endTime..st b/Math-ODE.package/ODESolver.class/instance/lastStepState.endTime..st new file mode 100644 index 0000000..dd0a1f2 --- /dev/null +++ b/Math-ODE.package/ODESolver.class/instance/lastStepState.endTime..st @@ -0,0 +1,11 @@ +solving +lastStepState: aState endTime: endTime + "catch partial or full step at end" + (lastTime equalsTo: endTime ) + ifFalse: + [state := stepper + doStep: state + time: lastTime + stepSize: endTime - lastTime. + self announceState: state time: endTime]. + ^ state \ No newline at end of file diff --git a/Math-ODE.package/ODESolver.class/instance/mainStepsState.startTime.endTime..st b/Math-ODE.package/ODESolver.class/instance/mainStepsState.startTime.endTime..st new file mode 100644 index 0000000..7964237 --- /dev/null +++ b/Math-ODE.package/ODESolver.class/instance/mainStepsState.startTime.endTime..st @@ -0,0 +1,15 @@ +solving +mainStepsState: aState startTime: initialTime endTime: endTime + state := aState. + "don't go to end time to avoid overrunning" + (initialTime to: endTime - self dt by: self dt) do: + [:time | + state := stepper + doStep: state + time: time + stepSize: self dt. + "announce step results" + self announceState: state time: time + self dt. + lastTime := time + self dt]. + + ^ state \ No newline at end of file diff --git a/Math-ODE.package/ODESolver.class/instance/solve.startState.startTime.endTime..st b/Math-ODE.package/ODESolver.class/instance/solve.startState.startTime.endTime..st index 99312d2..c068b64 100644 --- a/Math-ODE.package/ODESolver.class/instance/solve.startState.startTime.endTime..st +++ b/Math-ODE.package/ODESolver.class/instance/solve.startState.startTime.endTime..st @@ -1,17 +1,21 @@ solving solve: aSystem startState: initialState startTime: initialTime endTime: endTime - | state | + self system: aSystem. stepper ifNil: [ self stepper: ((self stepperClass) onSystem: self system)]. state := initialState. - (initialTime to: endTime by: self dt) do: - [:time | - state := stepper - doStep: state - time: time - stepSize: self dt. - "announce step results" - announcer announce: (ExplicitSolverAnnouncement x: state t: time). - ]. + + "announce initial conditions" + self announceState: state time: initialTime. + "step until the end" + state := self mainStepsState: state startTime: initialTime endTime: endTime. + + "sanity check" + self assert: [(lastTime between: initialTime and: endTime) + or: [lastTime between: endTime and: initialTime]]. + + "take another step if needed" + state := self lastStepState: state endTime: endTime. + ^ state \ No newline at end of file diff --git a/Math-ODE.package/ODESolver.class/properties.json b/Math-ODE.package/ODESolver.class/properties.json index c3c2816..e27d0ed 100644 --- a/Math-ODE.package/ODESolver.class/properties.json +++ b/Math-ODE.package/ODESolver.class/properties.json @@ -10,7 +10,9 @@ "stepper", "system", "dt", - "announcer" ], + "announcer", + "lastTime", + "state" ], "name" : "ODESolver", "pools" : [ ], diff --git a/Math-ODE.package/RK4Solver.class/README.md b/Math-ODE.package/RK4Solver.class/README.md new file mode 100644 index 0000000..e9f35b9 --- /dev/null +++ b/Math-ODE.package/RK4Solver.class/README.md @@ -0,0 +1,3 @@ +A RK4Solver class is an ODESolver with default stepper type RungeKuttaStepper. + +This is a solver for first order explicit systems (a function of time and state yields the derivative). \ No newline at end of file diff --git a/Math-ODE.package/RK4Solver.class/class/stepperClass.st b/Math-ODE.package/RK4Solver.class/class/stepperClass.st new file mode 100644 index 0000000..6d1d731 --- /dev/null +++ b/Math-ODE.package/RK4Solver.class/class/stepperClass.st @@ -0,0 +1,3 @@ +class variables +stepperClass + ^ RungeKuttaStepper \ No newline at end of file diff --git a/Math-ODE.package/RK4Solver.class/properties.json b/Math-ODE.package/RK4Solver.class/properties.json new file mode 100644 index 0000000..a83d6a4 --- /dev/null +++ b/Math-ODE.package/RK4Solver.class/properties.json @@ -0,0 +1,16 @@ +{ + "category" : "Math-ODE", + "classinstvars" : [ + ], + "classtraitcomposition" : "{}", + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "RK4Solver", + "pools" : [ + ], + "super" : "ODESolver", + "traitcomposition" : "{}", + "type" : "normal" } diff --git a/Math-ODE.package/RungeKuttaStepper.class/instance/collectionDoStep.time..st b/Math-ODE.package/RungeKuttaStepper.class/instance/collectionDoStep.time..st index b124090..aee42a0 100644 --- a/Math-ODE.package/RungeKuttaStepper.class/instance/collectionDoStep.time..st +++ b/Math-ODE.package/RungeKuttaStepper.class/instance/collectionDoStep.time..st @@ -8,6 +8,5 @@ collectionDoStep: aState time: t k2 := system x: aState + (k1 * self stepSize / 2) t: midPoint. k3 := system x: aState + (k2 * self stepSize / 2 ) t: midPoint. k4 := system x: aState + (k3 * self stepSize) t: endPoint. - Transcript show: t; show: aState; cr. ^ aState + ((k1 + k2 + k2 + k3 + k3 + k4) / 6 * self stepSize). \ No newline at end of file diff --git a/Math-ODE.package/RungeKuttaStepper.class/instance/doStep.time..st b/Math-ODE.package/RungeKuttaStepper.class/instance/doStep.time..st index 17ac56c..71e7d14 100644 --- a/Math-ODE.package/RungeKuttaStepper.class/instance/doStep.time..st +++ b/Math-ODE.package/RungeKuttaStepper.class/instance/doStep.time..st @@ -1,10 +1,13 @@ stepping doStep: aState time: t "This method should take one step from inState at time t of size dt, and modify the state, then answer it." + | k1 k2 k3 k4 midPoint endPoint| self stepSize isNil ifTrue: [self error: 'step size required by stepper']. - aState isNumber - ifTrue: - [^ (self numberDoStep: aState time: t)] - "a collection" - ifFalse: - [^ (self collectionDoStep: aState time: t)] \ No newline at end of file + midPoint := self stepSize / 2 + t. + endPoint := self stepSize + t. + k1 := system x: aState t: t. + k2 := system x: aState + (k1 * self stepSize / 2) t: midPoint. + k3 := system x: aState + (k2 * self stepSize / 2 ) t: midPoint. + k4 := system x: aState + (k3 * self stepSize) t: endPoint. + ^ aState + ((k1 + k2 + k2 + k3 + k3 + k4) / 6 * self stepSize). + \ No newline at end of file diff --git a/Math-ODE.package/StateRecorder.class/README.md b/Math-ODE.package/StateRecorder.class/README.md index ee1c8cc..4129583 100644 --- a/Math-ODE.package/StateRecorder.class/README.md +++ b/Math-ODE.package/StateRecorder.class/README.md @@ -1,3 +1,3 @@ A StateRecorder captures each step in an ODESolvers history. -It stores these as a sorted collection of state,time points, in increasing time order. \ No newline at end of file +It stores these as a sorted collection of StateTime object, in increasing time order. \ No newline at end of file diff --git a/Math-ODE.package/StateRecorder.class/class/demo.st b/Math-ODE.package/StateRecorder.class/class/demo.st index 4107ec5..6fb6213 100644 --- a/Math-ODE.package/StateRecorder.class/class/demo.st +++ b/Math-ODE.package/StateRecorder.class/class/demo.st @@ -1,13 +1,17 @@ example demo -| solver system recorder | + | solver system recorder | -solver := ODESolver new. -system := ExplicitSystem block: [:x :t | t]. -recorder := self forSolver: solver. -solver solve: system startState: 0 startTime: 0 endTime: 2 stepSize: 0.1. + solver := RK4Solver new. + system := ExplicitSystem block: [:x :t | x collect: [:i | t]]. "exact solution x = 0.5 * t squared + x0" -recorder unsubscribe. -"these wont be captured" -solver solve: system startState: 0 startTime: 0 endTime: 5 stepSize: 0.1. -recorder states inspect. \ No newline at end of file + recorder := self forSolver: solver. + "an example of moving backward in time with fractional dt" + solver solve: system startState: #(3 1) startTime: 2 endTime: 0 stepSize: (-1 / 10). + + recorder unsubscribe. + + "these wont be captured. an example of moving forward in time with float dt." + solver solve: system startState: #(0) startTime: 0 endTime: 5 stepSize: 0.1. + + recorder states inspect. \ No newline at end of file diff --git a/Math-ODE.package/StateRecorder.class/instance/add.at..st b/Math-ODE.package/StateRecorder.class/instance/add.at..st index a8dd3cc..3ef9052 100644 --- a/Math-ODE.package/StateRecorder.class/instance/add.at..st +++ b/Math-ODE.package/StateRecorder.class/instance/add.at..st @@ -1,3 +1,3 @@ accessing add: aState at: aTime - states add: aState @ aTime \ No newline at end of file + states add: (StateTime state: aState time: aTime). \ No newline at end of file diff --git a/Math-ODE.package/StateRecorder.class/instance/initialize.st b/Math-ODE.package/StateRecorder.class/instance/initialize.st index 468fe93..c6fa72d 100644 --- a/Math-ODE.package/StateRecorder.class/instance/initialize.st +++ b/Math-ODE.package/StateRecorder.class/instance/initialize.st @@ -1,5 +1,5 @@ initialize-release initialize super initialize. - states := SortedCollection sortBlock: [:x :y | x y < y y]. + states := SortedCollection sortBlock: [:x :y | x time < y time]. ^ self \ No newline at end of file diff --git a/Math-ODE.package/StateTime.class/README.md b/Math-ODE.package/StateTime.class/README.md new file mode 100644 index 0000000..fe86cbe --- /dev/null +++ b/Math-ODE.package/StateTime.class/README.md @@ -0,0 +1,3 @@ +A StateTime class is a generalization of point. It holds both a state and a time. + +We don't want to use Point, since state may be a vector quantity, and the behavior of array @ number is a little off (it stores points in an array, what we want is the array itself in state, and the scalar quantity in time). \ No newline at end of file diff --git a/Math-ODE.package/StateTime.class/class/state.time..st b/Math-ODE.package/StateTime.class/class/state.time..st new file mode 100644 index 0000000..5f7091f --- /dev/null +++ b/Math-ODE.package/StateTime.class/class/state.time..st @@ -0,0 +1,5 @@ +instance creation +state: aState time: aTime + ^ self new + state: aState; + time: aTime. \ No newline at end of file diff --git a/Math-ODE.package/StateTime.class/instance/printOn..st b/Math-ODE.package/StateTime.class/instance/printOn..st new file mode 100644 index 0000000..076efa4 --- /dev/null +++ b/Math-ODE.package/StateTime.class/instance/printOn..st @@ -0,0 +1,6 @@ +accessing +printOn: aStream + "used for inspector. Using the point analogy" + state printOn: aStream. + aStream nextPut: $@. + time printOn: aStream. diff --git a/Math-ODE.package/StateTime.class/instance/state..st b/Math-ODE.package/StateTime.class/instance/state..st new file mode 100644 index 0000000..4c13097 --- /dev/null +++ b/Math-ODE.package/StateTime.class/instance/state..st @@ -0,0 +1,3 @@ +accessing +state: anObject + state := anObject \ No newline at end of file diff --git a/Math-ODE.package/StateTime.class/instance/state.st b/Math-ODE.package/StateTime.class/instance/state.st new file mode 100644 index 0000000..577014e --- /dev/null +++ b/Math-ODE.package/StateTime.class/instance/state.st @@ -0,0 +1,3 @@ +accessing +state + ^ state \ No newline at end of file diff --git a/Math-ODE.package/StateTime.class/instance/time..st b/Math-ODE.package/StateTime.class/instance/time..st new file mode 100644 index 0000000..7db5aad --- /dev/null +++ b/Math-ODE.package/StateTime.class/instance/time..st @@ -0,0 +1,3 @@ +accessing +time: anObject + time := anObject \ No newline at end of file diff --git a/Math-ODE.package/StateTime.class/instance/time.st b/Math-ODE.package/StateTime.class/instance/time.st new file mode 100644 index 0000000..26d7040 --- /dev/null +++ b/Math-ODE.package/StateTime.class/instance/time.st @@ -0,0 +1,3 @@ +accessing +time + ^ time \ No newline at end of file diff --git a/Math-ODE.package/StateTime.class/properties.json b/Math-ODE.package/StateTime.class/properties.json new file mode 100644 index 0000000..0401269 --- /dev/null +++ b/Math-ODE.package/StateTime.class/properties.json @@ -0,0 +1,17 @@ +{ + "category" : "Math-ODE", + "classinstvars" : [ + ], + "classtraitcomposition" : "{}", + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + "state", + "time" ], + "name" : "StateTime", + "pools" : [ + ], + "super" : "Object", + "traitcomposition" : "{}", + "type" : "normal" } diff --git a/Math-ODE.package/TranscriptRecorder.class/README.md b/Math-ODE.package/TranscriptRecorder.class/README.md index cb55cf1..168b6ca 100644 --- a/Math-ODE.package/TranscriptRecorder.class/README.md +++ b/Math-ODE.package/TranscriptRecorder.class/README.md @@ -1,2 +1,4 @@ A TranscriptRecorder is a very primitive tool. -It prints a message to transcript when a step is taken by the solver. \ No newline at end of file +It prints a message to transcript when a step is taken by the solver. + +The demo class method shows an example. \ No newline at end of file diff --git a/Math-ODE.package/TranscriptRecorder.class/class/demo.st b/Math-ODE.package/TranscriptRecorder.class/class/demo.st index a0537a1..6570f0f 100644 --- a/Math-ODE.package/TranscriptRecorder.class/class/demo.st +++ b/Math-ODE.package/TranscriptRecorder.class/class/demo.st @@ -6,12 +6,13 @@ Transcript cr; show: 'TranscriptRecorder demo start'; cr. -solver := ODESolver new. -system := ExplicitSystem block: [:x :t | t]. +solver := RK4Solver new. +system := ExplicitSystem block: [:x : t | x collect: [:ea | t]]. +Transcript show: system block; cr. recorder := self forSolver: solver. -"this should be shown" -solver solve: system startState: 0 startTime: 0 endTime: 2 stepSize: 0.1. +"this should be shown, explicit solution is x=1/2*t^2" +solver solve: system startState: #(1 2 3 4) startTime: 0 endTime: 2 stepSize: 0.1. recorder unsubscribe. "this should not be shown" -solver solve: system startState: 0 startTime: 0 endTime: 5 stepSize: 0.1. +solver solve: system startState: #(0) startTime: 0 endTime: 5 stepSize: 0.1. Transcript show: 'TranscriptRecorder demo end'; cr. \ No newline at end of file diff --git a/Math-ODE.package/monticello.meta/version b/Math-ODE.package/monticello.meta/version index 79e96ea..15ebf56 100644 --- a/Math-ODE.package/monticello.meta/version +++ b/Math-ODE.package/monticello.meta/version @@ -1 +1 @@ -(name 'Math-ODE-DanielUber.11' message 'added announcements/watchers to ODESolver ' id '42c431f9-2754-4d1d-b60f-5d5c011c4ade' date '8 June 2012' time '11:43:43.202 am' author 'DanielUber' ancestors ((name 'Math-ODE-DanielUber.10' message 'RungeKuttaStepper added. Corrected issue where ODESolver would overwrite stepper.' id 'aa5aa7b0-eb57-457f-a08a-f9971db062b3' date '29 May 2012' time '11:38:04.988 am' author 'DanielUber' ancestors ((name 'Math-ODE-DanielUber.9' message 'working copy ' id '7356b953-4511-44c1-baed-671b73abdd00' date '29 May 2012' time '8:07:06.734 am' author 'DanielUber' ancestors ((name 'Math-ODE-DanielUber.8' message 'empty log message' id '5c0bc90a-2387-41bc-ab90-a88883002a50' date '23 May 2012' time '2:26:31.909 pm' author 'DanielUber' ancestors ((name 'Math-ODE-DanielUber.7' message 'added stepSize method to ODESolver to match documentation.' id '955dc50b-d09e-41cf-b8dd-f0ae03bc864f' date '22 May 2012' time '1:13:52.298 pm' author 'DanielUber' ancestors ((name 'Math-ODE-DanielUber.6' message 'added classes from odeint-v2. Need to flush out methods.' id 'ff724335-5ab4-435c-8c05-59aba765771b' date '22 May 2012' time '1:08:22.878 pm' author 'DanielUber' ancestors ((name 'Math-ODE-DanielUber.5' message 'removed stepSize method' id 'e61dae0a-b3ed-4cdb-a664-339a0f9b5b1e' date '22 May 2012' time '12:19:42.946 pm' author 'DanielUber' ancestors ((name 'Math-ODE-DanielUber.4' message 'added ODESolver. Need to seriously refactor this.' id '571a4c4d-eaf0-4e41-86c4-759345442aaa' date '22 May 2012' time '12:00:41.72 pm' author 'DanielUber' ancestors ((name 'Math-ODE-DanielUber.3' message 'added dostep:time:stepSize: to Explicit Stepper.' id '22698f56-b98a-42f8-aa9a-a5ebd7040fba' date '22 May 2012' time '11:00:33.138 am' author 'DanielUber' ancestors ((name 'Math-ODE-DanielUber.2' message 'added Stepper instance side order method' id '1985fcfd-5303-402a-9827-079a288c913c' date '22 May 2012' time '10:28:29.012 am' author 'DanielUber' ancestors ((name 'Math-ODE-DanielUber.1' message 'adding tests ' id 'b3f035a5-9b7e-4620-82d1-01b71791d425' date '22 May 2012' time '10:22:15.344 am' author 'DanielUber' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file +(name 'Math-ODE-DanielUber.12' message 'changes to Math-ODE' id '905b6525-b095-4a6c-84b4-6dc52a76d4ff' date '10 June 2012' time '10:52:11.954 am' author 'DanielUber' ancestors ((name 'Math-ODE-DanielUber.11' message 'added announcements/watchers to ODESolver ' id '42c431f9-2754-4d1d-b60f-5d5c011c4ade' date '8 June 2012' time '11:43:43.202 am' author 'DanielUber' ancestors ((name 'Math-ODE-DanielUber.10' message 'RungeKuttaStepper added. Corrected issue where ODESolver would overwrite stepper.' id 'aa5aa7b0-eb57-457f-a08a-f9971db062b3' date '29 May 2012' time '11:38:04.988 am' author 'DanielUber' ancestors ((name 'Math-ODE-DanielUber.9' message 'working copy ' id '7356b953-4511-44c1-baed-671b73abdd00' date '29 May 2012' time '8:07:06.734 am' author 'DanielUber' ancestors ((name 'Math-ODE-DanielUber.8' message 'empty log message' id '5c0bc90a-2387-41bc-ab90-a88883002a50' date '23 May 2012' time '2:26:31.909 pm' author 'DanielUber' ancestors ((name 'Math-ODE-DanielUber.7' message 'added stepSize method to ODESolver to match documentation.' id '955dc50b-d09e-41cf-b8dd-f0ae03bc864f' date '22 May 2012' time '1:13:52.298 pm' author 'DanielUber' ancestors ((name 'Math-ODE-DanielUber.6' message 'added classes from odeint-v2. Need to flush out methods.' id 'ff724335-5ab4-435c-8c05-59aba765771b' date '22 May 2012' time '1:08:22.878 pm' author 'DanielUber' ancestors ((name 'Math-ODE-DanielUber.5' message 'removed stepSize method' id 'e61dae0a-b3ed-4cdb-a664-339a0f9b5b1e' date '22 May 2012' time '12:19:42.946 pm' author 'DanielUber' ancestors ((name 'Math-ODE-DanielUber.4' message 'added ODESolver. Need to seriously refactor this.' id '571a4c4d-eaf0-4e41-86c4-759345442aaa' date '22 May 2012' time '12:00:41.72 pm' author 'DanielUber' ancestors ((name 'Math-ODE-DanielUber.3' message 'added dostep:time:stepSize: to Explicit Stepper.' id '22698f56-b98a-42f8-aa9a-a5ebd7040fba' date '22 May 2012' time '11:00:33.138 am' author 'DanielUber' ancestors ((name 'Math-ODE-DanielUber.2' message 'added Stepper instance side order method' id '1985fcfd-5303-402a-9827-079a288c913c' date '22 May 2012' time '10:28:29.012 am' author 'DanielUber' ancestors ((name 'Math-ODE-DanielUber.1' message 'adding tests ' id 'b3f035a5-9b7e-4620-82d1-01b71791d425' date '22 May 2012' time '10:22:15.344 am' author 'DanielUber' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file