Ejemplo n.º 1
0
def test2():
    v = Vector()
    v.p0 = np.ones(3)
    assert_true(np.allclose(v, -np.ones(3)))
    assert_true(np.allclose(v.p0, np.ones(3)))
    assert_true(np.allclose(v.p, np.zeros(3)))

    v = Vector(p=[1., 1., 1.], p0=[1., 1., 1.])
    assert_true(np.allclose(v, np.zeros(3)))
    assert_true(np.allclose(v.p0, np.ones(3)))
    assert_true(np.allclose(v.p, np.ones(3)))
    v.p0 = np.zeros(3)
    assert_true(np.allclose(v, np.ones(3)))
    assert_true(np.allclose(v.p0, np.zeros(3)))
    assert_true(np.allclose(v.p, np.ones(3)))
    v.x = 5.0
    assert_equal(v.x, 5.0)
    assert_equal(v.x, v.p.x)
    v.y = -5.0
    assert_equal(v.y, -5.0)
    assert_equal(v.y, v.p.y)
    v.z = 0.0
    assert_equal(v.z, 0.0)
    assert_equal(v.z, v.p.z)

    v.p0 = np.array([0.5, -10.0, 2.5])
    assert_equal(v.p0.x, 0.5)
    assert_equal(v.p0.y, -10.0)
    assert_equal(v.p0.z, 2.5)
Ejemplo n.º 2
0
def test2():
    v = Vector()
    v.p0 = np.ones(3)
    assert_true(np.allclose(v, -np.ones(3)))
    assert_true(np.allclose(v.p0, np.ones(3)))
    assert_true(np.allclose(v.p, np.zeros(3)))

    v = Vector(p=[1., 1., 1.], p0=[1., 1., 1.])
    assert_true(np.allclose(v, np.zeros(3)))
    assert_true(np.allclose(v.p0, np.ones(3)))
    assert_true(np.allclose(v.p, np.ones(3)))
    v.p0 = np.zeros(3)
    assert_true(np.allclose(v, np.ones(3)))
    assert_true(np.allclose(v.p0, np.zeros(3)))
    assert_true(np.allclose(v.p, np.ones(3)))
    v.x = 5.0
    assert_equal(v.x, 5.0)
    assert_equal(v.x, v.p.x)
    v.y = -5.0
    assert_equal(v.y, -5.0)
    assert_equal(v.y, v.p.y)
    v.z = 0.0
    assert_equal(v.z, 0.0)
    assert_equal(v.z, v.p.z)

    v.p0 = np.array([0.5, -10.0, 2.5])
    assert_equal(v.p0.x, 0.5)
    assert_equal(v.p0.y, -10.0)
    assert_equal(v.p0.z, 2.5)
Ejemplo n.º 3
0
    def generate_bundle_coords(self):
        """Generate coordinates of bundle tubes."""
        self.r1 = Vector()
        self.r2 = Vector()
        self.bundle_coords = []

        self.r1.x = self.dt + 2 * self.vdw_radius
        if self.bundle_packing in ('cubic', 'ccp'):
            self.r2.y = self.r1.x
        else:
            self.r2.x = self.r1.x * np.cos(2 * np.pi / 3)
            self.r2.y = self.r1.x * np.sin(2 * np.pi / 3)
            if self.bundle_packing is None:
                self._bundle_packing = 'hcp'

        if self.bundle_geometry == 'hexagon':
            nrows = max(self.nx, self.ny, 3)
            if nrows % 2 != 1:
                nrows += 1

            ntubes_per_end_rows = int((nrows + 1) / 2)

            row = 0
            ntubes_per_row = nrows
            while ntubes_per_row >= ntubes_per_end_rows:
                if row == 0:
                    for n in range(ntubes_per_row):
                        dr = n * self.r1
                        self.bundle_coords.append(dr)
                else:
                    for nx in range(ntubes_per_row):
                        for ny in (-row, row):
                            dr = Vector()
                            dr.x = abs(ny * self.r2.x)
                            dr.y = ny * self.r2.y
                            dr = nx * self.r1 + dr
                            self.bundle_coords.append(dr)
                row += 1
                ntubes_per_row = nrows - row

        elif self.bundle_geometry == 'rectangle':
            Lx = 10 * self.Lx
            for nx in range(self.nx):
                for ny in range(self.ny):
                    dr = nx * self.r1 + ny * self.r2
                    while dr.x < 0:
                        dr.x += Lx
                    self.bundle_coords.append(dr)

        elif self.bundle_geometry == 'square':
            pass
        elif self.bundle_geometry == 'triangle':
            pass
        else:
            for nx in range(self.nx):
                for ny in range(self.ny):
                    dr = nx * self.r1 + ny * self.r2
                    self.bundle_coords.append(dr)
Ejemplo n.º 4
0
    def generate_bundle_coords(self):
        """Generate coordinates of bundle tubes."""
        self.r1 = Vector()
        self.r2 = Vector()
        self.bundle_coords = []

        self.r1.x = self.dt + 2 * self.vdw_radius
        if self.bundle_packing in ('cubic', 'ccp'):
            self.r2.y = self.r1.x
        else:
            self.r2.x = self.r1.x * np.cos(2 * np.pi / 3)
            self.r2.y = self.r1.x * np.sin(2 * np.pi / 3)
            if self.bundle_packing is None:
                self._bundle_packing = 'hcp'

        if self.bundle_geometry == 'hexagon':
            nrows = max(self.nx, self.ny, 3)
            if nrows % 2 != 1:
                nrows += 1

            ntubes_per_end_rows = int((nrows + 1) / 2)

            row = 0
            ntubes_per_row = nrows
            while ntubes_per_row >= ntubes_per_end_rows:
                if row == 0:
                    for n in range(ntubes_per_row):
                        dr = n * self.r1
                        self.bundle_coords.append(dr)
                else:
                    for nx in range(ntubes_per_row):
                        for ny in (-row, row):
                            dr = Vector()
                            dr.x = abs(ny * self.r2.x)
                            dr.y = ny * self.r2.y
                            dr = nx * self.r1 + dr
                            self.bundle_coords.append(dr)
                row += 1
                ntubes_per_row = nrows - row

        elif self.bundle_geometry == 'rectangle':
            Lx = 10 * self.Lx
            for nx in range(self.nx):
                for ny in range(self.ny):
                    dr = nx * self.r1 + ny * self.r2
                    while dr.x < 0:
                        dr.x += Lx
                    self.bundle_coords.append(dr)

        elif self.bundle_geometry == 'square':
            pass
        elif self.bundle_geometry == 'triangle':
            pass
        else:
            for nx in range(self.nx):
                for ny in range(self.ny):
                    dr = nx * self.r1 + ny * self.r2
                    self.bundle_coords.append(dr)