-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsilo.py
More file actions
102 lines (83 loc) · 2.25 KB
/
Copy pathsilo.py
File metadata and controls
102 lines (83 loc) · 2.25 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
"""Setup script for silo"""
from pathlib import Path
import numpy as np
import matplotlib.pyplot as plt
import os
from python_scripts.utils.file_io import display, get_config_particlepath
import sys
print(f"DEBUG: Using Python at {sys.executable}")
import polars as pl
# Parse inputs and create folders etc.
config, particle_filepath = get_config_particlepath()
box = config["sim_box_size"]
base_particle = {
"t": 0.0,
"id": 0,
"ptype": 0,
"x" : 2.1,
"y" : 0.0,
"z" : 5.8,
"vx" : 0.0,
"vy" : 0.0,
"vz" : 0.0,
"qx" : 0.0,
"qy" : 0.0,
"qz" : 0.0,
"qw" : 1.0,
"wx" : 0.0,
"wy" : 0.0,
"wz" : 0.0,
"radius" : 0.04,
"mass" : 2.35,#density 1000kgm^-3
"r": 255.0,
"g": 0.0,
"b" : 0.0,
"a" : 255.0
}
particle = base_particle.copy()
d = base_particle["radius"]*2.1
df = pl.DataFrame(particle)
id=0
#Create a square grid of particles
particle = base_particle.copy()
for i in range(70):
for j in range(70):
particle["id"]=id
particle["x"] = base_particle["x"] + j*d
particle["z"] = base_particle["z"] + i*d
df_new = pl.DataFrame(particle)
if not i==j==0:
df=pl.concat([df, df_new])
id +=1
#Create a silo sides
particle = base_particle.copy()
angle_walls = 30.0 *np.pi/180.0
width_simbox = 10.0
num_wall_balls = int(1.5*width_simbox/(d))
x = np.linspace(0, 10.0,2*num_wall_balls)
z = np.abs((1/np.tan(angle_walls))*(x-5.0))
bottom_hopper = 2.0
for xval, zval in zip(x,z):
particle["id"]=id
particle["x"] = xval
particle["z"] = zval
if zval>= bottom_hopper:
particle["r"]=0.0
particle["b"]=255.0
particle["g"]=0.0
particle["ptype"]=1
else:
zval=bottom_hopper
particle["z"] = bottom_hopper
particle["r"]=0.0
particle["b"]=0.0
particle["g"]=255.0
particle["ptype"]=2
df=pl.concat([df, pl.DataFrame(particle)])
id += 1
df = df.with_columns(pl.col("ptype").cast(pl.UInt64))
df = df.with_columns(pl.col("id").cast(pl.UInt64))
print("max", df.select(pl.max("ptype")))
print(df)
df.write_parquet(particle_filepath)
display(df, box)