-
Notifications
You must be signed in to change notification settings - Fork 28
Incremental GA support starting from CSchankGA #4261
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
Changes from 41 commits
d084423
db3c270
986746d
4d90fe1
decb5ca
4644ec0
5269cd1
11eaa2b
edb9605
8f86213
2a3c2d3
702f9ac
b839e9c
723ef84
9abf5d3
3025eb5
b584df6
dad1ff9
df26aab
58a8950
c3de4b7
d7b6f28
bbd95c6
0521708
c09e081
5ae98e2
c0f02aa
b9438d1
88ab96f
aa69081
973b0af
74c695a
cb7f09e
2cf75ea
f6a9fd8
4b9f763
c27c968
03d8348
d3d043d
84ad7e3
717a4c3
fc9f53e
ef71df2
296a1a7
d005734
7932d10
750d737
73730eb
7a989c2
f574712
a892c0a
3b79be8
e45bf5b
f58a8e7
ca4f6a4
1de11bd
6496563
6716a06
0f5793c
2f2d762
e52d4c9
9bfa485
d8b270d
25c2072
7efc3dd
e9d0354
dfcd714
15a1ff6
9f73b0f
1d27129
56ba678
cf04af3
82a0599
23823bc
976a9d3
5fc5882
f85552a
080c7da
38750d8
495520b
aea893e
a65ada1
615a1fa
b291a7d
e53b68b
023272f
b24dd3d
9a7aa46
5b728ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,10 +10,8 @@ module Data.Drasil.ExternalLibraries.ODELibraries ( | |
| odeintPckg, odeintSymbols | ||
| ) where | ||
|
|
||
| import Language.Drasil (HasSymbol(symbol), HasUID(uid), MayHaveUnit(getUnit), | ||
| QuantityDict, HasSpace(typ), Space (Actor, Natural, Real, Void, Boolean, String, Array, Vect), implVar, | ||
| implVarUID, implVarUID', qw, compoundPhrase, nounPhrase, nounPhraseSP, label, | ||
| sub, Idea(getA), NamedIdea(term), Stage(..), (+++)) | ||
| import Language.Drasil hiding (dim) | ||
| import Language.Drasil.Space (ClifKind(..), Dimension(..)) | ||
| import Language.Drasil.Display (Symbol(Label, Concat)) | ||
|
|
||
| import Language.Drasil.Code (Lang(..), ExternalLibrary, Step, Argument, | ||
|
|
@@ -39,8 +37,8 @@ import Language.Drasil.Code (Lang(..), ExternalLibrary, Step, Argument, | |
| mkODELibNoPath, pubStateVar, privStateVar, | ||
| NamedArgument, narg) | ||
|
|
||
| import Drasil.Code.CodeExpr | ||
| import Drasil.Code.CodeExpr.Development | ||
| import Drasil.Code.CodeExpr hiding (dim) | ||
| import qualified Drasil.Code.CodeExpr.Development as CE | ||
|
|
||
| import Control.Lens ((^.), _1, _2, over) | ||
|
|
||
|
|
@@ -431,6 +429,11 @@ computeDerivatives = quantfunc $ implVar "computeDerivatives_apache" (nounPhrase | |
| odeintPckg :: ODELibPckg | ||
| odeintPckg = mkODELib "odeint" "v2" odeint odeintCall "." [Cpp] | ||
|
|
||
| -- | Symbolic dimension used for vector-valued ODE variables. | ||
| -- Allows examples to specialize this to "2", "3", etc., while keeping library code generic. | ||
| dim :: String | ||
| dim = "n" | ||
|
|
||
| odeint :: ExternalLibrary | ||
| odeint = externalLib [ | ||
| choiceSteps [ | ||
|
|
@@ -444,15 +447,20 @@ odeint = externalLib [ | |
| customObjArg [] "Class representing an ODE system" ode odeCtor | ||
| (customClass [constructorInfo odeCtor [] [], | ||
| methodInfoNoReturn odeOp "function representation of ODE system" | ||
| [unnamedParam (Vect Real), unnamedParam (Vect Real), lockedParam t] | ||
| -- | ODE parameters: generalized for vectors of symbolic dimension 'dim'. | ||
| -- TODO: Once ClifS is integrated, revisit this to allow symbolic multivectors as parameter types. | ||
| -- Likely replacement: ClifS dim Real instead of ClifS (VDim dim) Multivector Real. | ||
| [unnamedParam (ClifS (VDim dim) Multivector Real), unnamedParam (ClifS (VDim dim) Multivector Real), lockedParam t] | ||
|
||
| [assignArrayIndex]]), | ||
| -- [unnamedParam (ClifS (VDim dim) Multivector Real), unnamedParam (ClifS (VDim dim) Multivector Real), lockedParam t] | ||
| -- [assignArrayIndex]]), | ||
| -- Need to declare variable holding initial value because odeint will update this variable at each step | ||
| preDefinedArg odeintCurrVals, | ||
| inlineArg Real, inlineArg Real, inlineArg Real, | ||
| customObjArg [] | ||
| "Class for populating a list during an ODE solution process" | ||
| pop popCtor (customClass [ | ||
| constructorInfo popCtor [unnamedParam (Vect Real)] [], | ||
| constructorInfo popCtor [unnamedParam (ClifS (VDim dim) Multivector Real)] [], | ||
|
||
| methodInfoNoReturn popOp | ||
| "appends solution point for current ODE solution step" | ||
| [lockedParam y, lockedParam t] [appendCurrSol (sy y)]])]] | ||
|
|
@@ -497,7 +505,7 @@ odeintCurrVals, rk, stepper, pop :: CodeVarChunk | |
| odeintCurrVals = quantvar $ implVar "currVals_odeint" (nounPhrase | ||
| "vector holding ODE solution values for the current step" | ||
| "vectors holding ODE solution values for the current step") | ||
| (Vect Real) (label "currVals") | ||
| (ClifS (VDim dim) Multivector Real) (label "currVals") | ||
|
||
| rk = quantvar $ implVar "rk_odeint" (nounPhrase | ||
| "stepper for solving ODE system using Runge-Kutta-Dopri5 method" | ||
| "steppers for solving ODE system using Runge-Kutta-Dopri5 method") | ||
|
|
@@ -556,7 +564,7 @@ t = quantvar $ implVar "t_ode" (nounPhrase | |
| y = quantvar $ implVar "y_ode" (nounPhrase | ||
| "current dependent variable value in ODE solution" | ||
| "current dependent variable value in ODE solution") | ||
| (Vect Real) (label "y") | ||
| (ClifS (VDim dim) Multivector Real) (label "y") | ||
|
|
||
| -- | ODE object constructor. | ||
| odeCtor :: CodeFuncChunk | ||
|
|
@@ -586,35 +594,36 @@ diffCodeChunk c = quantvar $ implVarUID' (c +++ "d" ) | |
| modifiedODESyst :: String -> ODEInfo -> [CodeExpr] | ||
| modifiedODESyst sufx info = map replaceDepVar (odeSyst info) | ||
| where | ||
| replaceDepVar cc@(C c) | c == depVar info ^. uid = C $ depVar info +++ ("_" ++ sufx) | ||
| replaceDepVar cc@(CE.C c) | c == depVar info ^. uid = CE.C $ depVar info +++ ("_" ++ sufx) | ||
| | otherwise = cc | ||
| replaceDepVar (AssocA a es) = AssocA a (map replaceDepVar es) | ||
| replaceDepVar (AssocB b es) = AssocB b (map replaceDepVar es) | ||
| replaceDepVar (FCall u es nes) = FCall u (map replaceDepVar es) | ||
| replaceDepVar (CE.AssocA a es) = CE.AssocA a (map replaceDepVar es) | ||
| replaceDepVar (CE.AssocB b es) = CE.AssocB b (map replaceDepVar es) | ||
| replaceDepVar (CE.FCall u es nes) = CE.FCall u (map replaceDepVar es) | ||
| (map (over _2 replaceDepVar) nes) | ||
| replaceDepVar (New u es nes) = New u (map replaceDepVar es) | ||
| replaceDepVar (CE.New u es nes) = CE.New u (map replaceDepVar es) | ||
| (map (over _2 replaceDepVar) nes) | ||
| replaceDepVar (Message au mu es nes) = Message au mu (map replaceDepVar es) | ||
| replaceDepVar (CE.Message au mu es nes) = CE.Message au mu (map replaceDepVar es) | ||
| (map (over _2 replaceDepVar) nes) | ||
| replaceDepVar (Case c cs) = Case c (map (over _1 replaceDepVar) cs) | ||
| replaceDepVar (Matrix es) = Matrix $ map (map replaceDepVar) es | ||
| replaceDepVar (UnaryOp u e) = UnaryOp u $ replaceDepVar e | ||
| replaceDepVar (UnaryOpB u e) = UnaryOpB u $ replaceDepVar e | ||
| replaceDepVar (UnaryOpVV u e) = UnaryOpVV u $ replaceDepVar e | ||
| replaceDepVar (UnaryOpVN u e) = UnaryOpVN u $ replaceDepVar e | ||
| replaceDepVar (ArithBinaryOp b e1 e2) = ArithBinaryOp b | ||
| replaceDepVar (CE.Case c cs) = CE.Case c (map (over _1 replaceDepVar) cs) | ||
| replaceDepVar (CE.Matrix es) = CE.Matrix $ map (map replaceDepVar) es | ||
| replaceDepVar (CE.UnaryOp u e) = CE.UnaryOp u $ replaceDepVar e | ||
| replaceDepVar (CE.UnaryOpB u e) = CE.UnaryOpB u $ replaceDepVar e | ||
| -- TODO: When ClifS or multivectors are introduced, add support for UnaryOpCC and UnaryOpCN here. | ||
| replaceDepVar (CE.UnaryOpCC u e) = CE.UnaryOpCC u $ replaceDepVar e | ||
| replaceDepVar (CE.UnaryOpCN u e) = CE.UnaryOpCN u $ replaceDepVar e | ||
| replaceDepVar (CE.ArithBinaryOp b e1 e2) = CE.ArithBinaryOp b | ||
| (replaceDepVar e1) (replaceDepVar e2) | ||
| replaceDepVar (BoolBinaryOp b e1 e2) = BoolBinaryOp b | ||
| replaceDepVar (CE.BoolBinaryOp b e1 e2) = CE.BoolBinaryOp b | ||
| (replaceDepVar e1) (replaceDepVar e2) | ||
| replaceDepVar (EqBinaryOp b e1 e2) = EqBinaryOp b | ||
| replaceDepVar (CE.EqBinaryOp b e1 e2) = CE.EqBinaryOp b | ||
| (replaceDepVar e1) (replaceDepVar e2) | ||
| replaceDepVar (LABinaryOp b e1 e2) = LABinaryOp b | ||
| replaceDepVar (CE.LABinaryOp b e1 e2) = CE.LABinaryOp b | ||
| (replaceDepVar e1) (replaceDepVar e2) | ||
| replaceDepVar (OrdBinaryOp b e1 e2) = OrdBinaryOp b | ||
| replaceDepVar (CE.OrdBinaryOp b e1 e2) = CE.OrdBinaryOp b | ||
| (replaceDepVar e1) (replaceDepVar e2) | ||
| replaceDepVar (VVNBinaryOp b e1 e2) = VVNBinaryOp b | ||
| replaceDepVar (CE.CCNBinaryOp b e1 e2) = CE.CCNBinaryOp b | ||
| (replaceDepVar e1) (replaceDepVar e2) | ||
| replaceDepVar (VVVBinaryOp b e1 e2) = VVVBinaryOp b | ||
| replaceDepVar (CE.CCCBinaryOp b e1 e2) = CE.CCCBinaryOp b | ||
| (replaceDepVar e1) (replaceDepVar e2) | ||
| replaceDepVar (Operator ao dd e) = Operator ao dd $ replaceDepVar e | ||
| replaceDepVar (CE.Operator ao dd e) = CE.Operator ao dd $ replaceDepVar e | ||
| replaceDepVar e = e | ||
Uh oh!
There was an error while loading. Please reload this page.