forked from BlackHolePerturbationToolkit/ReggeWheeler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReggeWheelerRadial.m
67 lines (53 loc) · 2.52 KB
/
ReggeWheelerRadial.m
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
(* ::Package:: *)
BeginPackage["ReggeWheeler`ReggeWheelerRadial`",
{
"ReggeWheeler`NumericalIntegration`"
}];
ReggeWheelerRadial::usage = "ReggeWheelerRadial[s, l, \[Omega]] computes solutions to the Regge Wheeler equation."
ReggeWheelerRadialFunction::usage = "ReggeWheelerRadialFunction[s, l, \[Omega], assoc] an object representing solutions to the Regge Wheeler equation."
Begin["`Private`"];
Options[ReggeWheelerRadial] = {Method -> {"NumericalIntegration", "rmin" -> 4, "rmax" -> 20}, "BoundaryConditions" -> {"In","Up"}};
ReggeWheelerRadial[s_Integer, l_Integer, \[Omega]_, OptionsPattern[]] :=
Module[{assoc, solFuncs, method},
Switch[OptionValue[Method],
"MST"|{"MST", ___},
method = {"MST"};
solFuncs = $Failed,
{"NumericalIntegration", "rmin" -> _, "rmax" -> _},
method = Association[OptionValue[Method][[2;;]]];
solFuncs =
{ReggeWheeler`NumericalIntegration`Private`PsiIn[s, l, \[Omega], method["rmin"], method["rmax"]],
ReggeWheeler`NumericalIntegration`Private`PsiUp[s, l, \[Omega], method["rmin"], method["rmax"]]};
];
assoc = Association[
"Method" -> OptionValue["Method"],
"BoundaryConditions" -> OptionValue["BoundaryConditions"],
"SolutionFunctions" -> solFuncs
];
ReggeWheelerRadialFunction[s, l, \[Omega], assoc]
];
Format[ReggeWheelerRadialFunction[s_, l_, \[Omega]_, assoc_]] :=
"ReggeWheelerRadialFunction["<>ToString[s]<>","<>ToString[l]<>","<>ToString[\[Omega]]<>",<<>>]";
ReggeWheelerRadialFunction[s_, l_, \[Omega]_, assoc_][y:("In"|"Up")] :=
Module[{assocNew=assoc},
assocNew["SolutionFunctions"] = First[Pick[assoc["SolutionFunctions"], assoc["BoundaryConditions"], y]];
assocNew["BoundaryConditions"] = y;
ReggeWheelerRadialFunction[s, l, \[Omega], assocNew]
];
ReggeWheelerRadialFunction[s_, l_, \[Omega]_, assoc_][y_String] /; !MemberQ[{"SolutionFunctions"},y]:= assoc[y];
ReggeWheelerRadialFunction[s_, l_, \[Omega]_, assoc_][r_?NumericQ] := Module[{},
If[
Head[assoc["BoundaryConditions"]] === List,
Return[Association[MapThread[#1 -> #2["Psi"][r] &, {assoc["BoundaryConditions"], assoc["SolutionFunctions"]}]]],
Return[assoc["SolutionFunctions"]["Psi"][r]]
];
];
Derivative[n_][ReggeWheelerRadialFunction[s_, l_, \[Omega]_, assoc_]][r_?NumericQ] := Module[{},
If[
Head[assoc["BoundaryConditions"]] === List,
Return[Association[MapThread[#1 -> #2["dPsidr"][r] &, {assoc["BoundaryConditions"], assoc["SolutionFunctions"]}]]],
Return[assoc["SolutionFunctions"]["dPsidr"][r]]
];
];
End[]
EndPackage[];