Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UPDATED FFD.PY FILE WITH ROTATION MATRIX AS INPUT #262

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions pygem/ffd.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ def __init__(self, n_control_points=None):

self.box_length = np.array([1., 1., 1.])
self.box_origin = np.array([0., 0., 0.])
self.rot_mode = 0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a documentation for the two new members

self.rot_angle = np.array([0., 0., 0.])
self.rot_matrix = np.eye(3)

self.array_mu_x = None
self.array_mu_y = None
Expand Down Expand Up @@ -206,15 +208,23 @@ def T_mapping(points):

@property
def rotation_matrix(self):
"""
The rotation matrix (according to rot_angle_x, rot_angle_y,
rot_angle_z).

:rtype: numpy.ndarray
"""
return angles2matrix(np.radians(self.rot_angle[2]),
np.radians(self.rot_angle[1]),
np.radians(self.rot_angle[0]))
if self.rot_mode == 0:
"""
The rotation matrix (according to rot_angle_x, rot_angle_y,
rot_angle_z).

:rtype: numpy.ndarray
"""
return angles2matrix(np.radians(self.rot_angle[2]),
np.radians(self.rot_angle[1]),
np.radians(self.rot_angle[0]))
else:
"""
The rotation matrix as input

:rtype: numpy.ndarray
"""
return self.rot_matrix

@property
def position_vertices(self):
Expand Down Expand Up @@ -269,6 +279,7 @@ def read_parameters(self, filename='parameters.prm'):
self.box_origin[1] = config.getfloat('Box info', 'box origin y')
self.box_origin[2] = config.getfloat('Box info', 'box origin z')

self.rot_mode = config.getfloat('Box info', 'rotation mode')
self.rot_angle[0] = config.getfloat('Box info', 'rotation angle x')
self.rot_angle[1] = config.getfloat('Box info', 'rotation angle y')
self.rot_angle[2] = config.getfloat('Box info', 'rotation angle z')
Expand Down Expand Up @@ -358,6 +369,8 @@ def write_parameters(self, filename='parameters.prm'):
output_string += 'direction, use the following: rotation angle: '
output_string += '0., 0., 2.\n'

output_string += 'rotation mode: ' + str(self.rot_mode) + '\n'

output_string += 'rotation angle x: ' + str(self.rot_angle[0]) + '\n'
output_string += 'rotation angle y: ' + str(self.rot_angle[1]) + '\n'
output_string += 'rotation angle z: ' + str(self.rot_angle[2]) + '\n'
Expand Down Expand Up @@ -434,6 +447,7 @@ def __str__(self):
string += 'n_control_points = {}\n\n'.format(self.n_control_points)
string += 'box_length = {}\n'.format(self.box_length)
string += 'box_origin = {}\n'.format(self.box_origin)
string += 'rot_mode = {}\n'.format(self.rot_mode)
string += 'rot_angle = {}\n'.format(self.rot_angle)
string += '\narray_mu_x =\n{}\n'.format(self.array_mu_x)
string += '\narray_mu_y =\n{}\n'.format(self.array_mu_y)
Expand Down