def console_output(self, xopt, image_file):


        self.topology_factory.update_topology(xopt)
        tup = (2*self.topology_factory.a, 2*self.topology_factory.b)
        print('The element dimensions are (um): %gx%g' % tup)
        params = self.topology_factory.get_params()
        cantilever = microfem.Cantilever(*params)
        microfem.plot_topology(cantilever, image_file)

        if self.topology_factory.is_connected is True:

            fem = microfem.PlateFEM(self.material, cantilever)
            coords = (cantilever.xtip, cantilever.ytip)
            opr = microfem.PlateDisplacement(fem, coords).get_operator()
            mode_ident = microfem.ModeIdentification(fem, cantilever, 'plate')

            w, _, vall = fem.modal_analysis(self.n_modes)
            freq = np.sqrt(w) / (2*np.pi)
            kuu = fem.get_stiffness_matrix(free=False)
            phis = [vall[:, [i]] for i in range(self.n_modes)]
            wtips = [opr @ p for p in phis]
            kfunc = lambda p, w: np.asscalar(p.T @ kuu @ p / w ** 2)
            ks = [kfunc(p, w) for p, w in zip(phis, wtips)]
            types = [mode_ident.is_mode_flexural(p) for p in phis]

            tup = ('Disp', 'Freq (Hz)', 'Stiffness', 'Flexural')
            print('\n    %-15s %-15s %-15s %-10s' % tup)
            for i in range(self.n_modes):
                tup = (i, wtips[i], freq[i], ks[i], str(types[i]))
                print('%-2d: %-15g %-15g %-15g %-10s' % tup)

            for i in range(self.n_modes):
                microfem.plot_mode(fem, vall[:, i])
    def console_output(self, xopt, image_file):
        
        self.topology_factory.update_topology(xopt)
        topology = self.topology_factory.topology
        cantilever = microfem.Cantilever(topology, self.a, self.b)
        microfem.plot_topology(cantilever, image_file)
        
        if self.topology_factory.is_connected is True:
            
            fem = microfem.PlateFEM(self.material, cantilever)
            coords = (cantilever.xtip, cantilever.ytip)
            opr = PlateDisplacement(fem, coords).get_operator()
            mode_ident = ModeIdentification(fem, cantilever)
            
            w, _, vall = fem.modal_analysis(self.n_modes)
            freq = np.sqrt(w) / (2*np.pi)
            kuu = fem.get_stiffness_matrix(free=False)
            phis = [vall[:, [i]] for i in range(self.n_modes)]
            wtips = [opr @ p for p in phis]
            ks = [np.asscalar(p.T @ kuu @ p / w ** 2) for p, w in zip(phis, wtips)]
            costs = [k / ks[0] for k in ks]
            types = [mode_ident.is_mode_flexural(p) for p in phis]
            
            tup = ('Disp', 'Freq (Hz)', 'Stiffness', 'Ratio', 'Flexural')
            print('\n    %-15s %-15s %-15s %-15s %-10s' % tup)
            for i in range(self.n_modes):
                tup = (i, wtips[i], freq[i], ks[i], costs[i], str(types[i]))
                print('%-2d: %-15g %-15g %-15g %-15g %-10s' % tup)

            for i in range(self.n_modes):
                microfem.plot_mode(fem, vall[:, i])
                
    def console_output(self, xopt, image_file):

        self.topology_factory.update_topology(xopt)
        params = self.topology_factory.get_params()
        cantilever = microfem.Cantilever(*params)
        microfem.plot_topology(cantilever, image_file)

        if self.topology_factory.is_connected is True:

            fem = microfem.PlateFEM(self.material, cantilever)
            w, _, vall = fem.modal_analysis(1)
            f = np.asscalar(np.sqrt(w) / (2 * np.pi))
            print('The first modal frequency is (Hz): %g' % f)
            microfem.plot_mode(fem, vall[:, 0])
示例#4
0
    def to_console_final(self, xopt):

        print()
        print('--- Solution Characteristics ---')
        if self.exe_time != 0:
            print('Time (s): %g' % (self.exe_time))

        self.topology_factory.update_topology(xopt)
        topology = self.topology_factory.topology
        cantilever = microfem.Cantilever(topology, self.a, self.b)
        fn = ''.join((self.dir, '/', self.tag, '-image.png'))
        microfem.plot_topology(cantilever, fn)

        if self.topology_factory.is_connected is True:

            self.fem.update_mesh(cantilever)
            coords = (cantilever.xtip, cantilever.ytip)
            opr = PlateDisplacement(self.fem, coords).get_operator()
            mode_ident = ModeIdentification(self.fem, cantilever)

            w, _, vall = self.fem.modal_analysis(self.n_modes)
            freq = np.sqrt(w) / (2 * np.pi)
            kuu = self.fem.get_stiffness_matrix(free=False)
            phis = [vall[:, [i]] for i in range(self.n_modes)]
            wtips = [opr @ p for p in phis]
            ks = [
                np.asscalar(p.T @ kuu @ p / w**2) for p, w in zip(phis, wtips)
            ]
            costs = [k / ks[0] for k in ks]
            types = [mode_ident.is_mode_flexural(p) for p in phis]

            tup = ('Disp', 'Freq (Hz)', 'Stiffness', 'Ratio', 'Flexural')
            print('\n    %-15s %-15s %-15s %-15s %-10s' % tup)
            for i in range(self.n_modes):
                tup = (i, wtips[i], freq[i], ks[i], costs[i], str(types[i]))
                print('%-2d: %-15g %-15g %-15g %-15g %-10s' % tup)

            for i in range(self.n_modes):
                microfem.plot_mode(self.fem, vall[:, i])
示例#5
0
# With the FEM model buitl, modal analysis can be performed. This returns the
# resonance frequencies and mode shapes of the cantilever. These can then be
# plotted.
n_modes = 3
ws, _, vall = fem.modal_analysis(n_modes=n_modes)

# Using the results of the modal analysis, the frequency, stiffness,
# tip displacement, and mode type (flexural, torsional), can be determined.
coords = (cantilever.xtip, cantilever.ytip)
opr = microfem.LaminateDisplacement(fem, coords).get_operator()
mode_ident = microfem.ModeIdentification(fem, cantilever, type_='laminate')

freq = np.sqrt(ws) / (2 * np.pi)
kuu = fem.get_stiffness_matrix(free=False)
kuv = fem.get_piezoelectric_matrix(free=False)
phis = [vall[:, [i]] for i in range(n_modes)]
wtips = [opr @ p for p in phis]
kfunc = lambda p, w: np.asscalar(p.T @ kuu @ p / w**2)
ks = [kfunc(p, w) for p, w in zip(phis, wtips)]
charges = [kuv.T @ p / w for p, w in zip(phis, wtips)]
types = [mode_ident.is_mode_flexural(p) for p in phis]

tup = ('Disp', 'Freq (Hz)', 'Stiffness (N/m)', 'Flexural', 'Charge (C/m)')
print('\n    %-15s %-15s %-15s %-10s %-15s' % tup)
for i in range(n_modes):
    tup = (i + 1, wtips[i], freq[i], ks[i], str(types[i]), charges[i])
    print('%-2d: %-15g %-15g %-15g %-10s %-15g' % tup)

microfem.plot_mode(fem, vall[:, 0])
microfem.plot_mode(fem, vall[:, 1])
microfem.plot_mode(fem, vall[:, 2])