blob: 7940f4366edef4f7e494fda3b46039872ef23f03 (
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
|
import os
import numpy as np
import pickle
from chroma import *
models_directory = os.path.split(os.path.realpath(__file__))[0] + '/../models'
strings = 100
pmts_per_string = 100
radius = 50.0
height = 100.0
def build_lbne(bits=4):
lbne = geometry.Geometry()
sphere_mesh = stl.read_stl(models_directory + '/sphere.stl')
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(filename)
f.close()
return lbne
|