Skip to content
Snippets Groups Projects
Commit 7e4cc6f5 authored by Repo Updater's avatar Repo Updater
Browse files

76c061fb some work on the software engineering part

parent 5759530a
Branches
No related tags found
No related merge requests found
Showing
with 33 additions and 23 deletions
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import numpy as np import numpy as np
from numba import jit from numba import jit, njit
# parameters (global, for convenience) # parameters (global, for convenience)
n_iterations = 10 n_iterations = 10
...@@ -33,11 +33,11 @@ def init(val=0.5): ...@@ -33,11 +33,11 @@ def init(val=0.5):
return grid return grid
@jit(nopython=True)
def main_loop(evolve_func, grid): def main_loop(evolve_func, grid):
"""Main loop function, calling evolve_func on grid.""" """Main loop function, calling evolve_func on grid."""
grid_tmp = np.empty_like(grid) grid_tmp = np.empty_like(grid)
for i in range(1, n_iterations+1): for i in range(1, n_iterations+1):
apply_periodic_bc_python(grid, n_points)
evolve_func(grid, grid_tmp, n_points, dt, D) evolve_func(grid, grid_tmp, n_points, dt, D)
# swap references, do not copy # swap references, do not copy
if grid_tmp is not None: if grid_tmp is not None:
...@@ -47,7 +47,7 @@ def main_loop(evolve_func, grid): ...@@ -47,7 +47,7 @@ def main_loop(evolve_func, grid):
return grid return grid
@jit(nopython=True) @njit()
def apply_periodic_bc_python(grid, n_points): def apply_periodic_bc_python(grid, n_points):
"""Explicitly apply periodic boundary conditions, via Python loops.""" """Explicitly apply periodic boundary conditions, via Python loops."""
for j in range(n_points + 2): for j in range(n_points + 2):
...@@ -58,9 +58,8 @@ def apply_periodic_bc_python(grid, n_points): ...@@ -58,9 +58,8 @@ def apply_periodic_bc_python(grid, n_points):
grid[ i, 0] = grid[ i,-2] grid[ i, 0] = grid[ i,-2]
@jit(nopython=True) @njit
def evolve_python(grid, grid_tmp, n_points, dt, D): def evolve_python(grid, grid_tmp, n_points, dt, D):
apply_periodic_bc_python(grid, n_points)
for i in range(1, n_points+1): for i in range(1, n_points+1):
for j in range(1, n_points+1): for j in range(1, n_points+1):
# stencil formula # stencil formula
......
from setuptools import setup
setup(
name="HelloWorld",
version="0.1",
# specify a list of the packages (subdirectory with __init__.py file)
packages=["HelloWorld"],
# executable that comes with the package (if applicable)
scripts=['say_hello.py'],
# software dependencies (if necessary)
# install_requires=['docutils>=0.3'],
# metadata for upload to PyPI
author="Me",
author_email="me@example.com",
description="This is an Example Package",
license="PSF",
keywords="hello world example examples",
url="http://example.com/HelloWorld/", # project home page, if any
)
# init file of the HelloWorld example package, is automatically executed at 'import' # init file of the helloworld example package, is automatically executed at 'import'
from .lib import * from .lib import *
# implementation file, part of the "HelloWorld" demo Python package # implementation file, part of the "helloworld" demo Python package
def say_hello(): def say_hello():
print("Hello World!") print("Hello World!")
#!/usr/bin/env python3 #!/usr/bin/env python3
import HelloWorld import helloworld
HelloWorld.say_hello() helloworld.say_hello()
from setuptools import setup
setup(
# name of the software package (as it would appear on PyPI)
name="helloworld",
version="0.1",
# list of the Python modules provided by the package
packages=["helloworld"],
# list of executable(s) that come with the package (if applicable)
scripts=['say_hello.py'],
# list of package dependencies (if necessary)
#install_requires=['numpy'],
# more information, necessary for an upload to PyPI
author="John Doe",
author_email="john.doe@example.mpg.de",
description="example package that prints hello world",
license="PSF",
keywords="hello world example",
url="https://example.mpg.de/helloworld/", # project home page, if any
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment