Пример #1
0
    def d_a(self, k: float = 0.5, pretty=False):
        if not self.properties.geometry.solved:
            self.solvegeometry()
        d_a = 3.4 * math.pow(
            self.M_b() /
            ((1 - math.pow(k, 4)) * self.properties.material.sigma_bWN),
            1 / 3) * ureg.meter

        if pretty:
            formArray = [
                [self.M_b(pretty=True)[1].data[1:-1]],
                [
                    r"d_{a} = \approx 3.4 " + Latex.sqrt(
                        Latex.frac(r"M_{b}",
                                   r"\left(1 - k^4 \right) \sigma_{bWN}"), 3) +
                    r" \rightarrow 3.4 [m] " + Latex.sqrt(
                        Latex.frac(
                            self.M_b(),
                            r"\left(1 - " + str(k) + r"^{4} " + r"\right)" +
                            Latex.toStr(self.properties.material.sigma_bWN)),
                        3) + r" \approx " + Latex.toStr(d_a)
                ]
            ]
            pr = Latex.display(Latex.array(formArray))
            return [d_a, pr]
        else:
            return d_a
Пример #2
0
    def test_toStr(self):
        testStr = r"\sigma"
        testFloat = 0.666
        testInt = 666

        self.assertEqual(Latex.toStr(testStr), "\\sigma")
        self.assertEqual(Latex.toStr(testFloat), '6.66 \\cdot 10^{-1}')
        self.assertEqual(Latex.toStr(testInt), '6.66 \\cdot 10^{2}')
Пример #3
0
 def M_max(self, pretty=False):
     M_max = np.max(self.M) * ureg.N * ureg.m**-2
     if pretty:
         pr = Latex.display(
             Latex.toStr(r"M_{max} = \max(M_{nom}) \rightarrow " +
                         Latex.toStr(M_max)))
         return [M_max, pr]
     else:
         return M_max
Пример #4
0
def flowrate(v, A, pretty=False):
    Q = v * A
    Q = Q.to_base_units()
    if pretty:
        pr = Latex.display(Latex.toStr(
            r"Q_{f} = v_{f} \times A \rightarrow " + Latex.toStr(v) + r" \times " + Latex.toStr(
                A) + r" = " + Latex.toStr(Q)))
        return [Q, pr]
    return Q
Пример #5
0
 def M_b(self, pretty=False):
     M_b = self.M_max() * self.properties.appliancefactor.K_a
     if pretty:
         pr = Latex.display(
             Latex.toStr(r"M_{b} = K_A \max(M_{nom}) \times \rightarrow " +
                         Latex.toStr(self.properties.appliancefactor.K_a) +
                         r" \times " + Latex.toStr(self.M_max()) + r" = " +
                         Latex.toStr(self.M_b())))
         return [M_b, pr]
     else:
         return M_b
Пример #6
0
 def test_unit(self):
     test_unit_n = 0.666 * ureg.N
     test_unit_a = 3.333 * ureg.mm**2
     test_unit = test_unit_n / test_unit_a
     self.assertEqual(
         Latex.toStr(test_unit),
         '2.00 \\cdot 10^{-1} \\left[\\frac{N}{mm^{2}}\\right]')
Пример #7
0
 def test_combined(self):
     test_unit_n = 0.666 * ureg.N**2
     test_unit_a = 3.333 * ureg.mm**200
     test_unit_p = test_unit_n / test_unit_a
     test_result = math.sqrt(test_unit_p.magnitude) * ureg.Pa * ureg.m**-98
     self.assertEqual(
         r'$\sqrt{\frac{6.66 \cdot 10^{-1} \left[N^{2}\right]}{3.33 \left[mm^{200}\right]}} = 4.47 \cdot 10^{-1} \left[\frac{Pa}{m^{98}}\right]$',
         Latex.formulaprint(
             Latex.sqrt(Latex.frac(test_unit_n, test_unit_a)) + r" = " +
             Latex.toStr(test_result)))
Пример #8
0
    def d_prime(self, pretty=False):
        if not self.properties.geometry.solved:
            self.solvegeometry()
        d_prime = 3.4 * math.pow(
            self.M_b() / self.properties.material.sigma_bWN,
            1 / 3) * ureg.meter

        if pretty:
            formArray = [
                [self.M_b(pretty=True)[1].data[1:-1]],
                [
                    r"d^{'} = \approx 3.4 " +
                    Latex.sqrt(Latex.frac(r"M_{b}", r"\sigma_{bWN}"), 3) +
                    r" \rightarrow 3.4 [m] " + Latex.sqrt(
                        Latex.frac(self.M_b(),
                                   self.properties.material.sigma_bWN), 3) +
                    r" \approx " + Latex.toStr(d_prime)
                ]
            ]
            pr = Latex.display(Latex.array(formArray))
            return [d_prime, pr]
        else:
            return d_prime
Пример #9
0
def Reynolds(v, D, rho=None, mu=None, nu=None, fluid=None, pretty=False):
    if mu is not None and rho is not None:
        Re = (v * D * rho) / mu
        Re = Re.to_base_units()
        if pretty:
            pr = Latex.display(
                Latex.toStr(r"Re = \frac{v{f} \times D_i \times \rho_{f}}{\mu_{f}} \rightarrow \frac{" + Latex.toStr(
                    v) + r" \times " + Latex.toStr(D) + r" \times " + Latex.toStr(rho) + r"}{" + Latex.toStr(
                    mu) + r"} = " + Latex.toStr(Re)))
            return [Re, pr]
        else:
            return Re
    elif nu is not None:
        Re = (v * D) / nu
        Re = Re.to_base_units()
        if pretty:
            pr = Latex.display(
                Latex.toStr(r"Re = \frac{v{f} \times D_{i}}{\nu_{f}} \rightarrow \frac{" + Latex.toStr(
                    v) + r" \times " + Latex.toStr(D) + r" \times " + Latex.toStr(rho) + r"}{" + Latex.toStr(
                    mu) + r"} = " + Latex.toStr(Re)))
            return [Re, pr]
        else:
            return Re
    elif fluid is not None:
        Re = (v * D.to('m') * fluid.rho) / fluid.mu
        Re = Re.to_base_units()
        if pretty:
            pr = Latex.display(Latex.toStr(
                r"Re = \frac{v{f} \times D_i \times \rho_{f}}{\mu_{f}} \rightarrow \frac{" + Latex.toStr(
                    v) + r" \times " + Latex.toStr(D) + r" \times " + Latex.toStr(fluid.rho) + r"}{" + Latex.toStr(
                    fluid.mu) + r"} = " + Latex.toStr(Re)))
            return [Re, pr]
        else:
            return Re
    else:
        print('Error! Either fill in mu, nu or a fluid')
        return None
    return Re