forked from hyschive/gamer-fork
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtracer_utilties.py
More file actions
46 lines (32 loc) · 1.57 KB
/
Copy pathtracer_utilties.py
File metadata and controls
46 lines (32 loc) · 1.57 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
import numpy as np
import re
#====================================================================================================
# Function
#====================================================================================================
def LoadValueFromInputFile(filename, key_list):
regex_num = r"\s*([-+]?\d+\.?\d*[eE]?[-+]?\d*)"
param = dict()
with open(filename, "r") as f:
param_in = f.read()
for key in key_list:
value = re.findall(key + regex_num, param_in)
# assume the value is a float
param[key] = float(value[0])
return param
def AnalyticalDens(ParX, ParY, Center, Dens_Bg, BoxSize):
# use the formulae in SetGridIC() from the ParticleTest test problem
# to compute the density at these particles' locations
Radius = np.hypot(ParX - Center[0], ParY - Center[1])
return Dens_Bg * (1.0 + 5.0 * Radius / BoxSize)
def AnalyticalPres(ParX, ParY, Center, Pres_Bg, BoxSize):
# use the formulae in SetGridIC() from the ParticleTest test problem
# to compute the pressure at these particles' locations
Radius = np.hypot(ParX - Center[0], ParY - Center[1])
return Pres_Bg * (1.0 + 5.0 * Radius / BoxSize)
def AnalyticalVelX(ParX, ParY, Center, Ang_Freq):
# use the formulae in SetGridIC() from the ParticleTest test problem
# to compute the velocity in the x direction at these particles' locations
Radius = np.hypot(ParX - Center[0], ParY - Center[1])
Sin_Theta = (ParY - Center[1]) / Radius
Velocity = Ang_Freq * Radius
return -1.0 * Velocity * Sin_Theta