コード例 #1
0
    def _get_factory_task(self):
        yf = YoshimuraCPFactory(L_x=self.L_x,
                                L_y=self.L_y,
                                n_x=self.n_x,
                                n_y=self.n_y,
                                node='Waterbomb shell factory')
        cp = yf.formed_object
        N_h = yf.N_h
        N_i = yf.N_i
        N_v = yf.N_v

        e = (self.a + 2 * self.c) / 3.0
        d_x = e - self.c
        cp.X[N_h[1::3, :].flatten(), 0] -= d_x
        cp.X[N_h[2::3, :].flatten(), 0] += d_x
        cp.X[N_i[0::3, :].flatten(), 0] += d_x
        cp.X[N_i[2::3, :].flatten(), 0] -= d_x

        cp.X[N_v[0, :], 0] -= 0.05
        cp.X[N_v[-1, :], 0] += 0.05

        n_N = cp.n_N

        X_add_left = np.copy(cp.X[N_h[0, :], :])
        X_add_right = np.copy(cp.X[N_h[-1, :], :])
        X_add_left[:, 0] -= 0.05
        X_add_right[:, 0] += 0.05

        n_added = 2 * len(X_add_left)
        N_add = n_N + np.arange(n_added).reshape(2, -1)

        cp.X = np.vstack([cp.X, X_add_left, X_add_right])

        L_add_HL = np.vstack([N_h[0, :], N_add[0, :]]).T
        L_add_HR = np.vstack([N_h[-1, :], N_add[-1, :]]).T
        L_add_VD = np.vstack([N_v[:, :].reshape(1, -1),
                              N_add[:, :-1].reshape(1, -1)]).T
        L_add_VU = np.vstack([N_v[:, :].reshape(1, -1),
                              N_add[:, 1:].reshape(1, -1)]).T

        cp.L = np.vstack([cp.L, L_add_HL, L_add_HR,
                          L_add_VD, L_add_VU])

        F_add_L = np.c_[N_h[(0, -1), :-1].flatten(),
                        N_v[(0, -1), :].flatten(),
                        N_add[(0, -1), :-1].flatten()]
        F_add_U = np.c_[N_h[(0, -1), 1:].flatten(),
                        N_v[(0, -1), :].flatten(),
                        N_add[(0, -1), 1:].flatten()]

        n_F = len(cp.F)
        cp.F = np.vstack([cp.F, F_add_L, F_add_U])

        print(cp.F_L[n_F:])

        return yf
コード例 #2
0
def create_cp():
    # begin
    from oricreate.api import YoshimuraCPFactory

    cp_factory = YoshimuraCPFactory()
    cp = cp_factory.formed_object

    print('Nodes of facets enumerated counter clock-wise\n', cp.F_N)
    print('Lines of facets enumerated counter clock-wise\n', cp.F_L)
    # end
    return cp
コード例 #3
0
def test_crease_pattern_state_transitions():
    '''Test the moment and normal force calculated for a cross section.
    '''

    cp_factory = YoshimuraCPFactory(n_x=1, n_y=2, L_x=4, L_y=2)
    cp = cp_factory.formed_object

    assert np.allclose(
        cp.x,
        np.array([[0., 0., 0.], [0., 2., 0.], [4., 0., 0.], [4., 2., 0.],
                  [0., 1., 0.], [4., 1., 0.], [2., 1., 0.]]))

    cp.u[2, 2] = 1.0
    cp.u = cp.u
    assert cp.x[2, 2] == 1.0
コード例 #4
0
    def _get_factory_task(self):
        yf = YoshimuraCPFactory(L_x=self.L_x,
                                L_y=self.L_y,
                                n_x=self.n_x,
                                n_y=self.n_y)
        cp = yf.formed_object
        N_h = yf.N_h
        N_i = yf.N_i

        e = (self.a + 2 * self.c) / 3.0
        print('e', e)
        d_x = e - self.c
        print('delta', d_x)
        cp.X[N_h[1::3, :].flatten(), 0] -= d_x
        cp.X[N_h[2::3, :].flatten(), 0] += d_x
        cp.X[N_i[0::3, :].flatten(), 0] += d_x
        cp.X[N_i[2::3, :].flatten(), 0] -= d_x
        return yf
コード例 #5
0
    def _get_factory_task(self):
        yf = YoshimuraCPFactory(L_x=self.L_x * self.n_cell_x,
                                L_y=self.L_y * self.n_cell_y,
                                n_x=self.n_x,
                                n_y=self.n_y)
        cp = yf.formed_object
        N_h = yf.N_h
        N_i = yf.N_i

        dx = self.L_x / 3 * (1.0 - self.xi)

        print('***shortest length', self.L_x / 2.0 - dx)

        cp.X[N_h[1::3, :].flatten(), 0] -= dx
        cp.X[N_h[2::3, :].flatten(), 0] += dx
        cp.X[N_i[0::3, :].flatten(), 0] += dx
        cp.X[N_i[2::3, :].flatten(), 0] -= dx
        return yf
コード例 #6
0
ファイル: ex03_3b_4x8.py プロジェクト: bmcs-group/oricreate
 def _get_factory_task(self):
     return YoshimuraCPFactory(L_x=self.L_x, L_y=self.L_y,
                               n_x=self.n_x, n_y=self.n_y)
コード例 #7
0
                ax.annotate('%5.3f,%5.3f' % (x_v, y_v),
                            xy=(x_v, y_v),
                            rotation=90)
            ax.annotate('scaffold x - position %5.3f' % -s_pos, xy=(0, 0.04))

            fname_path = os.path.join(tdir, 'scaff%d.pdf' % idx)
            print('saving in %s', fname_path)
            p.savefig(fname_path)

        p.show()


if __name__ == '__main__':
    from oricreate.api import YoshimuraCPFactory, \
        CreasePattern, CustomCPFactory
    cpf = YoshimuraCPFactory(L_x=4, L_y=2, n_x=3, n_y=4)
    #     cp = CreasePattern(X=[[0, 0, 0],
    #                           [2, 0, 0],
    #                           [0, 2, 0],
    #                           ],
    #                        L=[[0, 1], [2, 0], [2, 1]],
    #                        F=[[0, 1, 2]])
    #     cpf = CustomCPFactory(formed_object=cp)
    cpf.formed_object.x[20, 2] = 0.5
    me = InfoCadMeshExporter(forming_task=cpf, n_l_e=8)

    me.write()

    X, F = me._get_geometry()

    x, y, z = X.T
コード例 #8
0
'''
Created on Apr 3, 2015

@author: rch
'''

import matplotlib.pyplot as plt
from oricreate.api import YoshimuraCPFactory
cp_factory = YoshimuraCPFactory(L_x=4, L_y=1, n_x=5, n_y=2)
cp = cp_factory.formed_object
print('list of sector angle arrays\n', cp.iN_theta)
print('facet area', cp.F_area)
print('potential energy', cp.V)
print('gradient of potential energy with respect to node displacements u\n',
      cp.V_du)

fig, ax = plt.subplots()
cp.plot_mpl(ax, facets=True, lines=False, linewidth=2, fontsize=30)
fig.patch.set_visible(False)
ax.axis('off')
# plt.tight_layout()
plt.show()
コード例 #9
0
def create_cp_factory():
    # begin
    from oricreate.api import YoshimuraCPFactory
    cp_factory = YoshimuraCPFactory(n_x=1, n_y=2, L_x=2, L_y=1)
    # end
    return cp_factory
コード例 #10
0
'''
Created on Apr 3, 2015

@author: rch
'''

import matplotlib.pyplot as plt
from oricreate.api import YoshimuraCPFactory
cp_factory = YoshimuraCPFactory(L_x=0.634, n_x=6, L_y=0.406, n_y=4)
cp = cp_factory.formed_object

fig, ax = plt.subplots()
cp.plot_mpl(ax, facets=True, lines=True, linewidth=4, fontsize=30)
fig.patch.set_visible(False)
ax.axis('on')
# plt.tight_layout()
plt.show()