Beispiel #1
0
    def objective_function(self, xs):

        self.topology_factory.update_topology(xs)

        if self.topology_factory.is_connected is True:

            params = self.topology_factory.get_params()
            cantilever = microfem.Cantilever(*params)
            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')

            try:
                w, _, vall = fem.modal_analysis(1)
            except RuntimeError:
                print('singular')
            kuu = fem.get_stiffness_matrix(free=False)
            f1 = np.asscalar(np.sqrt(w) / (2 * np.pi))
            phi1 = vall[:, [0]]
            wtip1 = np.asscalar(opr @ phi1)
            kfunc = lambda p, w: np.asscalar(p.T @ kuu @ p / w**2)
            k1 = kfunc(phi1, wtip1)
            type1 = mode_ident.is_mode_flexural(phi1)

            if type1 is False:
                cost = 1e8
            else:
                cost = -f1 * 1e-6 if k1 < self.k1 else k1

            return (cost, )

        return (self.topology_factory.connectivity_penalty, )
    def objective_function(self, xs):

        self.topology_factory.update_topology(xs)

        if self.topology_factory.is_connected is True:

            params = self.topology_factory.get_params()
            cantilever = microfem.Cantilever(*params)
            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)
            kuu = fem.get_stiffness_matrix(free=False)
            fs = np.sqrt(w) / (2*np.pi)
            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]

            if types[0] is False:
                cost = 1e8
            elif types[1] is True:
                cost = self.evaluation(fs[0], fs[1], ks[0], ks[1])
            elif types[2] is True:
                cost = self.evaluation(fs[0], fs[2], ks[0], ks[2])
            else:
                cost = 2e7

            return (cost,)

        return (self.topology_factory.connectivity_penalty,)
    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])
Beispiel #4
0
# The material properties for the SOI Mumps manufacturing process has been
# stored in an object. The plate finite element model requires both the
# cantilever object and material object to initialize.
material = microfem.SoiMumpsMaterial()
fem = microfem.PlateFEM(material, cantilever)

# With the FEM model built, 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.PlateDisplacement(fem, coords).get_operator()
mode_ident = microfem.ModeIdentification(fem, cantilever, type_='plate')

freq = np.sqrt(ws) / (2 * np.pi)
kuu = fem.get_stiffness_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)]
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(n_modes):
    tup = (i + 1, wtips[i], freq[i], ks[i], str(types[i]))
    print('%-2d: %-15g %-15g %-15g %-10s' % tup)