Skip to content

Commit

Permalink
from sympy import * now only imports needed functions and global vari…
Browse files Browse the repository at this point in the history
…ables, to avoid polluting namespace
  • Loading branch information
zachetienne committed May 28, 2020
1 parent 1ea1278 commit 7430ee3
Show file tree
Hide file tree
Showing 77 changed files with 270 additions and 318 deletions.
2 changes: 1 addition & 1 deletion BSSN/ADM_in_terms_of_BSSN.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# zachetie **at** gmail **dot* com

# Step 1.a: import all needed modules from NRPy+:
from outputC import * # NRPy+: Core C code output module
import NRPy_param_funcs as par # NRPy+: parameter interface
import sympy as sp # SymPy: The Python computer algebra package upon which NRPy+ depends
import indexedexp as ixp # NRPy+: Symbolic indexed expression (e.g., tensors, vectors, etc.) support
import reference_metric as rfm # NRPy+: Reference metric support
Expand Down
2 changes: 1 addition & 1 deletion BSSN/BSSN_in_terms_of_ADM.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# zachetie **at** gmail **dot* com

# Step 1: Import needed core NRPy+ modules
from outputC import * # NRPy+: Core C code output module
import sympy as sp # SymPy: The Python computer algebra package upon which NRPy+ depends
import NRPy_param_funcs as par # NRPy+: Parameter interface
import indexedexp as ixp # NRPy+: Symbolic indexed expression (e.g., tensors, vectors, etc.) support
import reference_metric as rfm # NRPy+: Reference metric support
Expand Down
1 change: 1 addition & 0 deletions BSSN/Psi4Cartesianvalidation/BSSN/ADM_in_terms_of_BSSN.py
1 change: 1 addition & 0 deletions BSSN/Psi4Cartesianvalidation/BSSN/BSSN_quantities.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,15 +555,15 @@
"source": [
"outCparams = \"preindent=1,outCfileaccess=w,outCverbose=False,includebraces=False\"\n",
"print(\"STARTING NEW\")\n",
"fin.FD_outputC(\"Psi4_new.h\", lhrh(lhs=\"psi4_real\", rhs=psi4_im), outCparams)\n",
"fin.FD_outputC(\"Psi4_new.h\", lhrh(lhs=\"psi4_real\", rhs=psi4_re), outCparams)\n",
"print(\"FINISHED NEW\")\n",
"\n",
"gri.glb_gridfcs_list = []\n",
"\n",
"import WeylScal4NRPy.WeylScalars_Cartesian as W4\n",
"W4.WeylScalars_Cartesian()\n",
"print(\"STARTING OLD\")\n",
"fin.FD_outputC(\"Psi4_old.h\", lhrh(lhs=\"psi4_real\", rhs=W4.psi4i), outCparams)\n",
"fin.FD_outputC(\"Psi4_old.h\", lhrh(lhs=\"psi4_real\", rhs=W4.psi4r), outCparams)\n",
"print(\"FINISHED OLD\")\n",
"\n",
"# print(\"FullSimplify[\"+str(sp.mathematica_code(psi4_re-W4.psi4r))+\"]\")\n",
Expand All @@ -586,17 +586,9 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"GOOD: 4.212367439480772e-16 : 1.178217177542785e-08 1.178217177542786e-08\r\n"
]
}
],
"outputs": [],
"source": [
"!gcc -O2 psi4_tester.c -o psi4_tester -lm\n",
"!./psi4_tester 4 4 4"
Expand Down Expand Up @@ -634,11 +626,8 @@
}
],
"source": [
"!jupyter nbconvert --to latex --template ../../latex_nrpy_style.tplx --log-level='WARN' Tutorial-Psi4-Cartesian_validation.ipynb\n",
"!pdflatex -interaction=batchmode Tutorial-Psi4-Cartesian_validation.tex\n",
"!pdflatex -interaction=batchmode Tutorial-Psi4-Cartesian_validation.tex\n",
"!pdflatex -interaction=batchmode Tutorial-Psi4-Cartesian_validation.tex\n",
"!rm -f Tut*.out Tut*.aux Tut*.log"
"import cmdline_helper as cmd # NRPy+: Multi-platform Python command-line interface\n",
"cmd.output_Jupyter_notebook_to_LaTeXed_PDF(\"Tutorial-Psi4-Cartesian_validation\")"
]
}
],
Expand All @@ -658,7 +647,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
"version": "3.8.3"
}
},
"nbformat": 4,
Expand Down
1 change: 1 addition & 0 deletions CurviBoundaryConditions/CurviBoundaryConditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# First we import needed core NRPy+ modules
from outputC import * # NRPy+: Core C code output module
import NRPy_param_funcs as par # NRPy+: Parameter interface
import sympy as sp # SymPy: The Python computer algebra package upon which NRPy+ depends
import grid as gri # NRPy+: Functions having to do with numerical grids
import indexedexp as ixp # NRPy+: Symbolic indexed expression (e.g., tensors, vectors, etc.) support
import reference_metric as rfm # NRPy+: Reference metric support
Expand Down
2 changes: 1 addition & 1 deletion GRFFE/equations.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Patrick Nelson

# Step 1: Import needed core NRPy+ modules
from outputC import * # NRPy+: Core C code output module
import sympy as sp # SymPy: The Python computer algebra package upon which NRPy+ depends
import indexedexp as ixp # NRPy+: Symbolic indexed expression (e.g., tensors, vectors, etc.) support

# Step 2: Define needed quantities for T_{EM}^{mu nu}, the EM part of the stress-energy tensor
Expand Down
2 changes: 2 additions & 0 deletions GRHD/equations.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

# Step 1: import all needed modules from NRPy+/Python:
from outputC import * # NRPy+: Core C code output module
import NRPy_param_funcs as par # NRPy+: Parameter interface
import sympy as sp # SymPy: The Python computer algebra package upon which NRPy+ depends
import indexedexp as ixp # NRPy+: Symbolic indexed expression (e.g., tensors, vectors, etc.) support

# Step 2: Define the stress-energy tensor
Expand Down
2 changes: 1 addition & 1 deletion GRMHD/equations.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# zachetie **at** gmail **dot* com

# Step 1: import all needed modules from NRPy+/Python:
from outputC import * # NRPy+: Core C code output module
import sympy as sp # SymPy: The Python computer algebra package upon which NRPy+ depends
import indexedexp as ixp # NRPy+: Symbolic indexed expression (e.g., tensors, vectors, etc.) support
import GRHD.equations as GRHD # NRPy+: Useful functions for general relativistic hydrodynamics
import GRFFE.equations as GRFFE # NRPy+: Useful functions for general relativistic force-free electrodynamics
Expand Down
2 changes: 2 additions & 0 deletions Min_Max_and_Piecewise_Expressions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from outputC import * # NRPy+: Core C code output module
import NRPy_param_funcs as par # NRPy+: parameter interface
import sympy as sp # SymPy: The Python computer algebra package upon which NRPy+ depends

thismodule = __name__

Expand Down
2 changes: 1 addition & 1 deletion Tutorial-ADMBSSN_tofrom_4metric.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
"version": "3.8.3"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion Tutorial-ADM_Initial_Data-Brill-Lindquist.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
"version": "3.8.3"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
"version": "3.8.3"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"source": [
"# Step 1: Initialize core Python/NRPy+ modules\n",
"from outputC import * # NRPy+: Core C code output module\n",
"import NRPy_param_funcs as par # NRPy+: Parameter interface\n",
"import sympy as sp # SymPy: The Python computer algebra package upon which NRPy+ depends\n",
"import finite_difference as fin # NRPy+: Finite difference C code generation module\n",
"import grid as gri # NRPy+: Functions having to do with numerical grids\n",
Expand Down Expand Up @@ -624,7 +625,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
"version": "3.8.3"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion Tutorial-ADM_Initial_Data-ShiftedKerrSchild.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
"version": "3.8.3"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion Tutorial-ADM_Initial_Data-TOV.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
"version": "3.8.3"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion Tutorial-ADM_Initial_Data-UIUC_BlackHole.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
"version": "3.8.3"
}
},
"nbformat": 4,
Expand Down
3 changes: 2 additions & 1 deletion Tutorial-ADM_in_terms_of_BSSN.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"source": [
"# Step 1.a: Import all needed modules from NRPy+\n",
"from outputC import * # NRPy+: Core C code output module\n",
"import NRPy_param_funcs as par # NRPy+: parameter interface\n",
"import sympy as sp # SymPy: The Python computer algebra package upon which NRPy+ depends\n",
"import indexedexp as ixp # NRPy+: Symbolic indexed expression (e.g., tensors, vectors, etc.) support\n",
"import reference_metric as rfm # NRPy+: Reference metric support\n",
Expand Down Expand Up @@ -533,7 +534,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
"version": "3.8.3"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"# Step P1: import all needed modules from NRPy+:\n",
"from outputC import * # NRPy+: Core C code output module\n",
"import finite_difference as fin # NRPy+: Finite difference C code generation module\n",
"import NRPy_param_funcs as par # NRPy+: parameter interface\n",
"import grid as gri # NRPy+: Functions having to do with numerical grids\n",
"import indexedexp as ixp # NRPy+: Symbolic indexed expression (e.g., tensors, vectors, etc.) support\n",
"import reference_metric as rfm # NRPy+: Reference metric support\n",
Expand Down Expand Up @@ -280,7 +281,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
"version": "3.8.3"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion Tutorial-BSSN_constraints.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
"version": "3.8.3"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion Tutorial-BSSN_formulation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
"version": "3.8.3"
}
},
"nbformat": 4,
Expand Down
3 changes: 2 additions & 1 deletion Tutorial-BSSN_in_terms_of_ADM.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"source": [
"# Step 1: Import needed core NRPy+ modules\n",
"from outputC import * # NRPy+: Core C code output module\n",
"import sympy as sp # SymPy: The Python computer algebra package upon which NRPy+ depends\n",
"import NRPy_param_funcs as par # NRPy+: Parameter interface\n",
"import indexedexp as ixp # NRPy+: Symbolic indexed expression (e.g., tensors, vectors, etc.) support\n",
"import reference_metric as rfm # NRPy+: Reference metric support\n",
Expand Down Expand Up @@ -522,7 +523,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
"version": "3.8.3"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion Tutorial-BSSN_quantities.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
"version": "3.8.3"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion Tutorial-BSSN_stress_energy_source_terms.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
"version": "3.8.3"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion Tutorial-BSSN_time_evolution-BSSN_RHSs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
"version": "3.8.3"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion Tutorial-BSSN_time_evolution-BSSN_gauge_RHSs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
"version": "3.8.3"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion Tutorial-Coutput__Parameter_Interface.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
"version": "3.8.3"
}
},
"nbformat": 4,
Expand Down
12 changes: 6 additions & 6 deletions Tutorial-ETK_thorn-FishboneMoncriefID.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Writing FishboneMoncriefID/src/InitialData.c\n"
"Overwriting FishboneMoncriefID/src/InitialData.c\n"
]
}
],
Expand Down Expand Up @@ -361,7 +361,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Writing FishboneMoncriefID/interface.ccl\n"
"Overwriting FishboneMoncriefID/interface.ccl\n"
]
}
],
Expand All @@ -387,7 +387,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Writing FishboneMoncriefID/param.ccl\n"
"Overwriting FishboneMoncriefID/param.ccl\n"
]
}
],
Expand Down Expand Up @@ -505,7 +505,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Writing FishboneMoncriefID/schedule.ccl\n"
"Overwriting FishboneMoncriefID/schedule.ccl\n"
]
}
],
Expand Down Expand Up @@ -568,7 +568,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Writing FishboneMoncriefID/src/make.code.defn\n"
"Overwriting FishboneMoncriefID/src/make.code.defn\n"
]
}
],
Expand Down Expand Up @@ -625,7 +625,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
"version": "3.8.3"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 7430ee3

Please sign in to comment.