@@ -111,14 +111,33 @@ def compute(self):
111
111
lmp .commands_string (f"atom_style { self .atomic_style } " )
112
112
num_type = self .type_list .max ()
113
113
create_box = f"""
114
- region 1 block 0 1 0 1 0 1
114
+ region 1 prism 0 1 0 1 0 1 0 0 0
115
115
create_box { num_type } 1
116
116
"""
117
117
lmp .commands_string (create_box )
118
- lmp .reset_box (* self .to_lammps_box (self .box ))
118
+ pos = self .pos
119
+ box = self .box
120
+ if box [0 , 1 ] != 0 or box [0 , 2 ] != 0 or box [1 , 2 ] != 0 :
121
+ old_box = box .copy ()
122
+ ax = np .linalg .norm (box [0 ])
123
+ bx = box [1 ] @ (box [0 ] / ax )
124
+ by = np .sqrt (np .linalg .norm (box [1 ]) ** 2 - bx ** 2 )
125
+ cx = box [2 ] @ (box [0 ] / ax )
126
+ cy = (box [1 ] @ box [2 ] - bx * cx ) / by
127
+ cz = np .sqrt (np .linalg .norm (box [2 ]) ** 2 - cx ** 2 - cy ** 2 )
128
+ box = np .array ([[ax , bx , cx ], [0 , by , cy ], [0 , 0 , cz ]]).T
129
+ rotation = np .linalg .solve (old_box [:- 1 ], box )
130
+ pos = self .pos @ rotation
131
+ box = np .r_ [box , box [- 1 ].reshape (1 , - 1 )]
132
+ # lmp.reset_box(*self.to_lammps_box(box))
133
+ lo , hi , xy , xz , yz = self .to_lammps_box (box )
134
+ lmp .commands_string (
135
+ f"change_box all x final { lo [0 ]} { hi [0 ]} y final { lo [1 ]} { hi [1 ]} z final { lo [2 ]} { hi [2 ]} xy final { xy } xz final { xz } yz final { yz } "
136
+ )
137
+
119
138
N = self .pos .shape [0 ]
120
139
N_lmp = lmp .create_atoms (
121
- N , np .arange (1 , N + 1 ), self .type_list , self . pos .flatten ()
140
+ N , np .arange (1 , N + 1 ), self .type_list , pos .flatten ()
122
141
)
123
142
assert N == N_lmp , "Wrong atom numbers."
124
143
0 commit comments