forked from lucaparisi91/pimc-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.py
92 lines (61 loc) · 1.77 KB
/
action.py
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
class action:
def __init__(self):
self.minimumDistance=0
self.mesh=False
class twoBodyPrimitiveAction(action):
def __init__( self, potential, groups ):
super().__init__()
self.potential=potential
self.groups=groups
def toJson(self):
return {
"kind": "twoBody",
"groupA": self.groups[0],
"groupB": self.groups[1],
"potential": self.potential.toJson()
}
class oneBodyAction(action):
def __init__( self, potential, group ):
super().__init__()
self.potential=potential
self.group=group
def toJson(self):
return {
"kind": "oneBody",
"group": self.group,
"potential": self.potential.toJson()
}
class actions:
def __init__(self,S=[]):
self._actions=S
def append(self,S):
self._actions.append(S)
def toJson(self):
return [ S.toJson() for S in self._actions ]
class caoBerneAction (action):
def __init__(self,a,groups,cutOff=None,mesh=False):
super().__init__()
self.a=a
self.groups=groups
self.cutOff=cutOff
self.mesh=mesh
self.minimumDistance=a
def toJson( self):
G={
"a": self.a,
"kind": "caoBerne"
}
if self.cutOff is not None:
G["kind"]="caoBerneTruncated"
G["cutOff"]=self.cutOff
if self.mesh:
kind="twoBodyMesh"
else:
kind="twoBody"
return {
"kind": kind,
"groupA": self.groups[0],
"groupB": self.groups[1],
"minimumDistance" : self.a,
"greenFunction": G
}