Ejemplo n.º 1
0
 def pol_coords(self):
     positions = np.zeros((len(self.positions), 3))
     for i, p in enumerate(self.positions):
         tmp = p - np.array(self.params['center'])
         tmp = self.swap_axis_inverse(tmp, self.params['axis'])
         positions[i, :] = tests_common.transform_pos_from_cartesian_to_polar_coordinates(
             tmp)
     return positions
Ejemplo n.º 2
0
 def pol_coords(self):
     positions = np.zeros((self.params['N'], 3))
     velocities = np.zeros((self.params['N'], 3))
     for i, p in enumerate(self.system.part):
         tmp = p.pos - np.array(self.params['center'])
         positions[
             i, :] = tests_common.transform_pos_from_cartesian_to_polar_coordinates(
                 tmp)
         velocities[
             i, :] = tests_common.transform_vel_from_cartesian_to_polar_coordinates(
                 tmp, p.v)
     return positions, velocities
Ejemplo n.º 3
0
    def setup_system_get_np_hist(self):
        """
        Pick positions and velocities in the original box frame and
        calculate the np histogram. Then rotate and move the positions
        and velocities to the frame of the observables.
        After calculating the core observables, the result should be
        the same as the np histogram obtained from the original box frame.
        """

        nodes = np.array(np.meshgrid([1, 2], [1, 2],
                                     [1, 1, 1, 1, 2])).T.reshape(-1, 3)
        positions = nodes + 3 * [0.5]
        velocities = self.calc_vel_at_pos(positions)

        # get the histogram from numpy
        pos_cyl = []
        for pos in positions:
            pos_cyl.append(
                tests_common.transform_pos_from_cartesian_to_polar_coordinates(
                    pos))
        np_hist, np_edges = tests_common.get_histogram(np.array(pos_cyl),
                                                       self.params,
                                                       'cylindrical')

        # the particles only determine the evaluation points, not the values of
        # the observables
        np_hist[np.nonzero(np_hist)] = 1

        # now align the positions and velocities with the frame of reference
        # used in the observables
        pos_aligned = []
        vel_aligned = []
        for pos, vel in zip(positions, velocities):
            pos_aligned.append(
                self.align_with_observable_frame(pos) +
                self.cyl_transform_params.center)
            vel_aligned.append(self.align_with_observable_frame(vel))
        node_aligned = np.array(np.rint(np.array(pos_aligned) - 3 * [0.5]),
                                dtype=int)
        self.system.part.add(pos=pos_aligned, v=vel_aligned)
        self.params['ids'] = self.system.part[:].id

        for node, vel in zip(node_aligned, vel_aligned):
            self.lbf[node].velocity = vel

        return np_hist, np_edges
Ejemplo n.º 4
0
    def setup_system_get_np_hist(self):
        """
        Pick positions and velocities in the original box frame
        and calculate the np histogram.
        Then rotate and move the positions and velocities
        to the frame of the observables.
        After calculating the core observables, the result should be
        the same as the np histogram obtained from the original box frame.
        """

        positions, velocities = self.calc_ellipsis_pos_vel(
            100,
            0.99 * self.params['min_z'],
            0.9 * self.params['max_z'],
            semi_x=0.9 * self.params['max_r'],
            semi_y=0.2 * self.params['max_r'])

        # first, get the numpy histogram of the cylinder coordinates
        pos_cyl = []
        for pos in positions:
            pos_cyl.append(
                tests_common.transform_pos_from_cartesian_to_polar_coordinates(
                    pos))
        np_hist, np_edges = tests_common.get_histogram(np.array(pos_cyl),
                                                       self.params,
                                                       'cylindrical')
        np_dens = tests_common.normalize_cylindrical_hist(
            np_hist.copy(), self.params)

        # now align the positions and velocities with the frame of reference
        # used in the observables
        pos_aligned = []
        vel_aligned = []
        for pos, vel in zip(positions, velocities):
            pos_aligned.append(
                self.align_with_observable_frame(pos) +
                self.cyl_transform_params.center)
            vel_aligned.append(self.align_with_observable_frame(vel))
        self.system.part.add(pos=pos_aligned, v=vel_aligned)
        self.params['ids'] = self.system.part.all().id

        return np_dens, np_edges