Exemple #1
0
    def generate_latex_output(self, calc_spec_tex_file_handle, sim, ui=None,
                              res_dir=None):
        """Generate calculation-specific part of the LaTeX output file"""
        average_pressure = np.mean(self.rot_ball.press[self.rot_ball.press > 0])
        numeric_output_data = [
            ('pressure, max.', to_preci(np.amax(self.rot_ball.press), 4),
             UnitTex.pressure.value, 'unverified'),
            ('pressure, av.', to_preci(average_pressure, 4),
             UnitTex.pressure.value, 'unverified'),
            ('e_a,kin, max.', to_preci(np.amax(self.e_akin), 4),
             UnitTex.eakin.value, 'unverified'),
            ('pv_rel, max.', to_preci(np.amax(self.pv), 4),
             UnitTex.pvrel.value, 'unverified'),
            ('contact area',
             to_preci(self.rot_ball.get_area(self.rot_ball.press), 4),
             UnitTex.area.value, 'unverified')]
        table_calc_summary = []
        for key, value, unit, status in sorted(numeric_output_data):
            table_calc_summary.append(
                (re.sub('_', '\_', key), value, unit, status))

        latex_variables = {'table_calc_summary': table_calc_summary,
                           'contact_plot1': '{}{}contact1.png'.format(
                               SubDir.tex_figs_rel_to_tex_file.value, '/'),
                           'pressure_plot1': '{}{}pressure1.png'.format(
                               SubDir.tex_figs_rel_to_tex_file.value, '/'),
                           'energy_plot1': '{}{}energy1.png'.format(
                               SubDir.tex_figs_rel_to_tex_file.value, '/')}
        template_calc_specific = get_calc_specific_latex_template(
            TexTempl.FourBall.value, sim)
        with open(calc_spec_tex_file_handle, 'w') as f:
            f.write(template_calc_specific.render(latex_variables))
Exemple #2
0
    def generate_latex_output(self, calc_spec_tex_file_handle, sim, ui=None,
                              res_dir=None):
        """Generate calculation-specific part of the LaTeX output file"""
        mean_press = np.mean(self.ring1.press[:, :][self.ring1.press[:, :] > 0])
        numeric_output_data = [
            ('pv_rel, max.', to_preci(np.amax(self.pv), 4),
             UnitTex.pvrel.value, 'unverified'),
            ('e_akin, max.', to_preci(np.amax(self.e_akin), 4),
             UnitTex.eakin.value, 'unverified'),
            ('pressure, max.', to_preci(np.amax(self.ring1.press[:, :]), 4),
             UnitTex.pressure.value, 'unverified'),
            ('pressure, av.', to_preci(mean_press, 4),
             UnitTex.pressure.value, 'unverified'),
            ('slip, max.', to_preci(np.amax(self.roller.slip) * 100, 4),
             '\%', 'unverified'),
            ('normal force, max.', to_preci(max(self.roller.norm_forces), 4),
             UnitTex.force.value, 'unverified'),
            ('contact area', to_preci(self.roller.get_area(self.ring1.press),
                                      4),
             UnitTex.area.value, 'unverified')]

        scale_factor_ir = 0.5 + 0.1 * (self.rot_vel1 != 0)
        scale_factor_or = 0.5 + 0.1 * (self.rot_vel2 != 0)

        table_calc_summary = []
        for key, value, unit, status in sorted(numeric_output_data):
            table_calc_summary.append(
                (re.sub('_', '\_', key), value, unit, status)
            )

        latex_variables = {'contact_plot1': 'figures{}contact1.png'.format('/'),
                           'pressure_plot1':
                               'figures{}pressure1.png'.format('/'),
                           'slip_plot1': 'figures{}slip1.png'.format('/'),
                           'energy_plot1': 'figures{}energy1.png'.format('/'),
                           'scale_factor_ir': scale_factor_ir,
                           'scale_factor_or': scale_factor_or,
                           'table_calc_summary': table_calc_summary}

        template_calc_specific = sim.latex_jinja_env.get_template(
            MasterDir.latex_templates.value +
            '/' +
            'template-axial-thrust-bearing.tex')
        with open(calc_spec_tex_file_handle, 'w') as f:
            f.write(template_calc_specific.render(latex_variables))
Exemple #3
0
    def generate_latex_output(self,
                              calc_spec_tex_file_handle,
                              sim,
                              ui=None,
                              res_dir=None):
        """Generate the calculation-specific part of the latex output file"""
        av_press_ring1 = np.mean(
            self.ring1.press[:, :, 0, 0][self.ring1.press[:, :, 0, 0] > 0])
        av_press_ring2 = np.mean(
            self.ring2.press[:, :, 0, 0][self.ring2.press[:, :, 0, 0] > 0])
        out_data = [
            ('pv_rel inner ring, max.', to_preci(np.amax(self.ring1.pv), 4),
             UnitTex.pvrel.value, 'unverified'),
            ('pv_rel outer ring, max.', to_preci(np.amax(self.ring2.pv), 4),
             UnitTex.pvrel.value, 'unverified'),
            ('e_akin inner ring, max.',
             to_preci(np.amax([self.ring1.e_akin]),
                      4), UnitTex.eakin.value, 'unverified'),
            ('e_akin outer ring, max.',
             to_preci(np.amax([self.ring2.e_akin]),
                      4), UnitTex.eakin.value, 'unverified'),
            ('pressure inner ring, max. av.', to_preci(av_press_ring1, 4),
             UnitTex.pressure.value, 'unverified'),
            ('pressure outer ring, max. av.', to_preci(av_press_ring2, 4),
             UnitTex.pressure.value, 'unverified'),
            ('normal force, max.', to_preci(np.amax(self.roller_norm_forces),
                                            4), UnitTex.force.value,
             'unverified'),
            ('pressure inner ring, max. max.',
             to_preci(np.amax(self.ring1.press[:, :, 0, 0]),
                      4), UnitTex.pressure.value, 'unverified'),
            ('pressure outer ring, max. max.',
             to_preci(np.amax(self.ring2.press[:, :, 0, 0]),
                      4), UnitTex.pressure.value, 'unverified'),
            ('contact area inner ring, max.',
             to_preci(self.roller.get_area(self.ring1.press[:, :, 0, 0]),
                      4), UnitTex.area.value, 'unverified'),
            ('contact area outer ring, max.',
             to_preci(self.roller.get_area(self.ring2.press[:, :, 0, 0]),
                      4), UnitTex.area.value, 'unverified')
        ]

        scale_factor_ir = 0.5 + 0.1 * (self.rot_vel1 != 0)
        scale_factor_or = 0.5 + 0.1 * (self.rot_vel2 != 0)

        table_calc_summary = []
        for key, value, unit, status in sorted(out_data):
            table_calc_summary.append((re.sub('_', '\_',
                                              key), value, unit, status))

        latex_variables = {
            'contact_plot1':
            '{}{}contact1.png'.format(SubDir.tex_figs_rel_to_tex_file.value,
                                      '/'),
            'contact_plot2':
            '{}{}contact2.png'.format(SubDir.tex_figs_rel_to_tex_file.value,
                                      '/'),
            'scale_factor_ir':
            scale_factor_ir,
            'scale_factor_or':
            scale_factor_or,
            'table_calc_summary':
            table_calc_summary,
            'load_plot1':
            '{}{}load1.png'.format(SubDir.tex_figs_rel_to_tex_file.value, '/'),
            'pressure_plot1':
            '{}{}pressure1.png'.format(SubDir.tex_figs_rel_to_tex_file.value,
                                       '/'),
            'pressure_plot2':
            '{}{}pressure2.png'.format(SubDir.tex_figs_rel_to_tex_file.value,
                                       '/'),
            'slip_plot1':
            '{}{}slip1.png'.format(SubDir.tex_figs_rel_to_tex_file.value, '/'),
            'energy_plot1':
            '{}{}energy1.png'.format(SubDir.tex_figs_rel_to_tex_file.value,
                                     '/'),
            'energy_plot2':
            '{}{}energy2.png'.format(SubDir.tex_figs_rel_to_tex_file.value,
                                     '/'),
            'energy_plot3':
            '{}{}energy3.png'.format(SubDir.tex_figs_rel_to_tex_file.value,
                                     '/')
        }

        template_calc_specific = get_calc_specific_latex_template(
            TexTempl.CylindricalRollerBearing.value, sim)
        with open(calc_spec_tex_file_handle, 'w') as f:
            f.write(template_calc_specific.render(latex_variables))