blob: 4473084f5fd432c8ae4f0125bfafeb49334f1500 (
plain)
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
|
import os
import numpy as np
import pickle
from chroma import *
models_directory = os.path.split(os.path.realpath(__file__))[0] + '/../models'
strings = 10
pmts_per_string = 10
radius = 10.0
height = 20.0
def build_lbne(bits=4):
lbne = geometry.Geometry()
sphere_mesh = stl.read_stl(models_directory + '/hamamatsu_12inch.stl')
sphere_mesh /= 1000.0
solids = []
for i in range(pmts_per_string):
for j in range(strings):
sphere = np.copy(sphere_mesh)
sphere += (-radius,0,i*(height/pmts_per_string))
sphere = transform.rotate(sphere, j*2*np.pi/strings, (0,0,1))
lbne.add_solid(geometry.Solid(sphere, materials.vacuum, materials.h2o))
lbne.build(bits)
return lbne
def cache_lbne(filename):
lbne = build_lbne(bits=8)
f = open(filename, 'wb')
pickle.dump(lbne, f)
f.close()
def load_lbne(filename):
f = open(filename, 'rb')
lbne = pickle.load(f)
f.close()
return lbne
if __name__ == '__main__':
build_lbne()
|