summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony LaTorre <telatorre@gmail.com>2011-05-23 19:33:02 -0400
committerAnthony LaTorre <telatorre@gmail.com>2011-05-23 19:33:02 -0400
commit36391a29dfb02a24e97b3ef9a3727201af415985 (patch)
treee1113c6aa310ba5f49c985b4fef0858b0d0f00d9
parent37b1d85c9f61190f223ee0cc6893c75c6c5f88cb (diff)
downloadchroma-36391a29dfb02a24e97b3ef9a3727201af415985.tar.gz
chroma-36391a29dfb02a24e97b3ef9a3727201af415985.tar.bz2
chroma-36391a29dfb02a24e97b3ef9a3727201af415985.zip
lbne model now imports python modules directly
-rw-r--r--detectors/lbne.py19
-rw-r--r--gputhread.py11
-rw-r--r--materials.py5
-rw-r--r--src/__init__.py (renamed from layout.py)3
-rwxr-xr-xview.py6
5 files changed, 26 insertions, 18 deletions
diff --git a/detectors/lbne.py b/detectors/lbne.py
index 7cd666a..ff38ef4 100644
--- a/detectors/lbne.py
+++ b/detectors/lbne.py
@@ -1,13 +1,20 @@
-import sys
import numpy as np
from copy import deepcopy
-from chroma import layout
-from chroma.stl import read_stl
-from chroma.transform import rotate
-from chroma.geometry import Geometry, Solid
-from chroma.materials import glass, h2o
from itertools import product
+import os
+import sys
+
+dir = os.path.split(os.path.realpath(__file__))[0]
+
+sys.path.append(dir + '/..')
+
+import layout
+from stl import read_stl
+from transform import rotate
+from geometry import Geometry, Solid
+from materials import glass, h2o
+
endcap_spacing = .485
radius = 25.0/10.0
diff --git a/gputhread.py b/gputhread.py
index fe05e4f..26520c4 100644
--- a/gputhread.py
+++ b/gputhread.py
@@ -2,8 +2,8 @@ import numpy as np
import pycuda.driver as cuda
from pycuda.compiler import SourceModule
import threading
-import layout
-from Queue import Empty
+import Queue
+import src
class Job(object):
def __init__(self, origins, directions):
@@ -28,16 +28,15 @@ class GPUThread(threading.Thread):
def run(self):
device = cuda.Device(self.device_id)
context = device.make_context()
- source = open(layout.source + '/kernel.cu').read()
- module = SourceModule(source, options=['-I' + layout.source], \
- no_extern_c=True, cache_dir=False)
+ module = SourceModule(src.kernel, options=['-I' + src.dir],
+ no_extern_c=True, cache_dir=False)
propagate = module.get_function('propagate')
texrefs = self.geometry.load(module)
while not self.stopped():
try:
job = self.jobs.get(timeout=2)
- except Empty:
+ except Queue.Empty:
continue
origins_gpu, directions_gpu = cuda.to_device(job.origins), \
diff --git a/materials.py b/materials.py
index 4a8058f..9160437 100644
--- a/materials.py
+++ b/materials.py
@@ -13,7 +13,10 @@ class Surface(object):
def __init__(self, name='none'):
self.name = name
- self.wavelength = None
+ self.wavelengths = None
+ self.transmission = None
+ self.reflection = None
+ self.absorption = None
air = Material('air')
h2o = Material('h2o')
diff --git a/layout.py b/src/__init__.py
index e192bd8..d2958f1 100644
--- a/layout.py
+++ b/src/__init__.py
@@ -2,5 +2,4 @@ import os
dir = os.path.split(os.path.realpath(__file__))[0]
-models = dir + '/models'
-source = dir + '/src'
+kernel = open(dir + '/kernel.cu').read()
diff --git a/view.py b/view.py
index 3958e05..e99c46e 100755
--- a/view.py
+++ b/view.py
@@ -4,7 +4,7 @@ import numpy as np
import pygame
from pygame.locals import *
-import layout
+import src
from camera import *
from geometry import *
from transform import *
@@ -35,8 +35,8 @@ def view(geometry, name=''):
print 'device %s' % autoinit.device.name()
- source = open(layout.source + '/kernel.cu').read()
- module = SourceModule(source, options=['-I' + layout.source], no_extern_c=True, cache_dir=False)
+ module = SourceModule(src.kernel, options=['-I' + src.dir],
+ no_extern_c=True, cache_dir=False)
texrefs = geometry.load(module)
cuda_raytrace = module.get_function('ray_trace')
cuda_rotate = module.get_function('rotate')