From 0d91f0d43efba28e91dc1a88b5f3acab9294b799 Mon Sep 17 00:00:00 2001 From: jan Date: Mon, 14 Aug 2017 15:41:20 -0700 Subject: [PATCH] rename lib --- fdtd.py | 7 ++++--- fdtd/__init__.py | 0 opencl_fdtd/__init__.py | 1 + {fdtd => opencl_fdtd}/kernels/common.cl | 0 {fdtd => opencl_fdtd}/kernels/update_e.cl | 0 {fdtd => opencl_fdtd}/kernels/update_h.cl | 0 {fdtd => opencl_fdtd}/kernels/update_s.cl | 0 {fdtd => opencl_fdtd}/simulation.py | 6 +++--- 8 files changed, 8 insertions(+), 6 deletions(-) delete mode 100644 fdtd/__init__.py create mode 100644 opencl_fdtd/__init__.py rename {fdtd => opencl_fdtd}/kernels/common.cl (100%) rename {fdtd => opencl_fdtd}/kernels/update_e.cl (100%) rename {fdtd => opencl_fdtd}/kernels/update_h.cl (100%) rename {fdtd => opencl_fdtd}/kernels/update_s.cl (100%) rename {fdtd => opencl_fdtd}/simulation.py (99%) diff --git a/fdtd.py b/fdtd.py index bbdabec..13af0fd 100644 --- a/fdtd.py +++ b/fdtd.py @@ -8,10 +8,10 @@ import sys import time import numpy -import lzma +import lzma import dill -from fdtd.simulation import Simulation +from opencl_fdtd import Simulation from masque import Pattern, shapes import gridlock import pcgen @@ -133,7 +133,7 @@ def main(): def field_source(i): t0 = i * sim.dt - delay return numpy.sin(w * t0) * numpy.exp(-alpha * t0**2) - + with open('sources.c', 'w') as f: f.write(sim.sources['E']) f.write('\n==========================================\n') @@ -172,5 +172,6 @@ def main(): d['S'] = unvec(sim.S.get()) dill.dump(d, f) + if __name__ == '__main__': main() diff --git a/fdtd/__init__.py b/fdtd/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/opencl_fdtd/__init__.py b/opencl_fdtd/__init__.py new file mode 100644 index 0000000..e3e95b4 --- /dev/null +++ b/opencl_fdtd/__init__.py @@ -0,0 +1 @@ +from .simulation import Simulation, type_to_C diff --git a/fdtd/kernels/common.cl b/opencl_fdtd/kernels/common.cl similarity index 100% rename from fdtd/kernels/common.cl rename to opencl_fdtd/kernels/common.cl diff --git a/fdtd/kernels/update_e.cl b/opencl_fdtd/kernels/update_e.cl similarity index 100% rename from fdtd/kernels/update_e.cl rename to opencl_fdtd/kernels/update_e.cl diff --git a/fdtd/kernels/update_h.cl b/opencl_fdtd/kernels/update_h.cl similarity index 100% rename from fdtd/kernels/update_h.cl rename to opencl_fdtd/kernels/update_h.cl diff --git a/fdtd/kernels/update_s.cl b/opencl_fdtd/kernels/update_s.cl similarity index 100% rename from fdtd/kernels/update_s.cl rename to opencl_fdtd/kernels/update_s.cl diff --git a/fdtd/simulation.py b/opencl_fdtd/simulation.py similarity index 99% rename from fdtd/simulation.py rename to opencl_fdtd/simulation.py index f1a8dec..77a95df 100644 --- a/fdtd/simulation.py +++ b/opencl_fdtd/simulation.py @@ -152,7 +152,7 @@ class Simulation(object): S_fields[ptr('oS')] = self.oS S_fields[ptr('S')] = self.S else: - S_fields = OrderedDict() + S_fields = OrderedDict() ''' PML @@ -167,7 +167,7 @@ class Simulation(object): p0 = numpy.exp(-(sigma + alpha) * dt) p1 = sigma / (sigma + alpha) * (p0 - 1) return p0, p1 - + xen, xep, xhn, xhp = (numpy.arange(1, pml_thickness + 1, dtype=float_type)[::-1] for _ in range(4)) xep -= 0.5 xhn -= 0.5 @@ -190,7 +190,7 @@ class Simulation(object): for ne, nh in zip(*psi_names): pml_e_fields[ptr(ne)] = pyopencl.array.zeros(self.queue, tuple(psi_shape), dtype=self.arg_type) pml_h_fields[ptr(nh)] = pyopencl.array.zeros(self.queue, tuple(psi_shape), dtype=self.arg_type) - + self.pml_e_fields = pml_e_fields self.pml_h_fields = pml_h_fields