示例#1
0
    def calculateCoeffs(self):
        """
        If forces exist, the respective coefficients are calculated accordingly.
        Otherwise a ValueError is raised.

        :param L: Reference length
        :type L: float
        :param A: Reference area
        :type A: float
        """
        self.uInf = Utilities.mag(self.inletVelocity)
        self.Re = FlowProperties.Re(L=self.L, u=self.uInf)
        self.Fr = FlowProperties.Fr(L=self.L, u=self.uInf)

        if self.forces:
            self.t = self.forces[0]
            self.resistances['RF'] = self.direction * self.forces[
                abs(self.direction) + 3]
            self.resistances['RT'] = self.resistances['RF'] +\
                                    self.direction*self.forces[abs(self.direction)]
            self.resistances['CF'] = Resistance.forceCoeff(
                self.resistances['RF'], self.A, u=self.uInf)
            self.resistances['CT'] = Resistance.forceCoeff(
                self.resistances['RT'], self.A, u=self.uInf)
        else:
            raise ValueError
 def testVelToFr(self):
     """
     Tests the conversion from velocity to Froude number
     """
     for vel, Froude in self.vFr:
         result = FlowProperties.Fr(u=vel, L=1.0, nu=Constants.water['nu'])
         self.assertEqual(Froude, result)
示例#3
0
def forceCoeff(F, Swett, u=None, Re=None, Fr=None, **kwargs):
    """
    Calculates the force coefficient by

    ..math::

        C = \\frac{F}{0.5\\rho S_{wett} u^2}

    :param F: Force
    :type F: float
    :param Swett: Wetted surface area
    :type Swett: float
    :param u: Velocity
    :type u: float
    :param Re: Reynoldsnumber
    :type Re: float
    :param Fr: Froudenumber
    :type Fr: float

    :rtype: float

    :Author: Jens Hoepken <*****@*****.**>
    """

    if not 'rho' in kwargs.iterkeys():
        rho = Constants.water['rho']
    else:
        rho = kwargs['rho']

    if Re:
        u = FlowProperties.Re(Re=Re, L=kwargs['L'])
    elif Fr:
        u = FlowProperties.Fr(Fr=Fr, L=kwargs['L'])

    return F / (0.5 * rho * Swett * u**2)
 def testFrToVel(self):
     """
     Tests the conversion from Froude nubmer to velocity
     """
     for vel, Froude in self.vFr:
         result = FlowProperties.Fr(Fr=Froude,
                                    L=1.0,
                                    nu=Constants.water['nu'])
         self.assertEqual(vel, result)
示例#5
0
    def updateInletVelocity(self):
        """
        Reads and updates the inlet velocity. This has to be done without
        pyFoam, as this takes *ages* for a file with precalculated
        velocities.
        """
        inletFound = False
        with open(join(self.name, self.first, 'U'), 'r') as bc:
            for line in bc:
                for patchI in self.inletPatch:
                    if patchI in line:
                        inletFound = True
                    if inletFound:
                        if "uniform" in line:
                            vIn = line
                            break

        numberRe = compile(r"[+-]? *(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?")
        self.inletVelocity = [float(uI) for uI in findall(numberRe, vIn)]
        self.uInf = Utilities.mag(self.inletVelocity)
        self.Re = FlowProperties.Re(L=self.L, u=self.uInf)
        self.Fr = FlowProperties.Fr(L=self.L, u=self.uInf)