Esempio n. 1
0
def block_coefficient(lpp, br, draft, vol, Cb, s):
    """
    lpp     : length between perpendiculars or wL length
    br      : some breadth (e.g. breadth at the waterline)
    draft   : draft
    vol     : volumetric displacement/water weight
    
            Vol/(Lwl*Bwl*Draft) = Cb
    """
    c1 = lp.Variable('c1')
    c2 = lp.Variable('c2')

    state = copy.copy(s)
    state.values[c1] = None
    state.values[c2] = None

    goal = lp.Goal.both(
        lp.Goal.both(lp.Goal.mulo(lpp, br, c1), lp.Goal.mulo(c1, draft, c2)),
        lp.Goal.divo(vol, c2, Cb))

    state = goal(goal(goal(state)[0])[0])[
        0]  #forward chaining!  maybe decorate or otherwise move outside

    del (state.values[c1])
    del (state.values[c2])
    dkeys = []
    for key in state.values:
        if not isinstance(key, lp.Variable):
            dkeys.append(key)
    for key in dkeys:
        del (state.values[key])
    return state  #s
Esempio n. 2
0
    def midship_coefficient(self):
        """
        Amsh    : Midship area
        Dsmax   : Draft at station of max section area
        Cmidshp    : Midship Coefficient
        
                Amsh/(Bwl*Dsmax) = Cmidshp
        """
        bwl = self.bwl
        dsmax = self.dsmax
        Amsh = self.Amsh
        Cmidshp = self.Cmidshp
        s = self.state

        c1 = lp.Variable('c1')
        state = copy.copy(s)
        state.values[c1] = None
        goal = lp.Goal.both(lp.Goal.mulo(dsmax, bwl, c1),
                            lp.Goal.divo(Amsh, c1, Cmidshp))
        state = goal(goal(state)[0])[0]
        del (state.values[c1])
        dkeys = []
        for key in state.values:
            if not isinstance(key, lp.Variable):
                dkeys.append(key)
        for key in dkeys:
            del (state.values[key])
        return state
Esempio n. 3
0
    def waterplane_coefficient(self):
        """
        Awp     : wateplane area
        lwl     : waterline length
        bwl     : waterline breadth
        Cwp     : waterplane coefficient
        
                Awp/(Lwl*Bwl) = Cwp
        """
        lwl = self.lwl
        bwl = self.bwl
        Awp = self.Awp
        Cwp = self.Cwp
        s = self.state

        c1 = lp.Variable('c1')
        state = copy.copy(s)
        state.values[c1] = None

        goal = lp.Goal.both(lp.Goal.mulo(lwl, bwl, c1),
                            lp.Goal.divo(Awp, c1, Cwp))

        state = goal(goal(state)[0])[0]
        del (state.values[c1])
        dkeys = []
        for key in state.values:
            if not isinstance(key, lp.Variable):
                dkeys.append(key)
        for key in dkeys:
            del (state.values[key])
        return state
Esempio n. 4
0
    def _setup_(self):
        self._draft = lp.Variable('draft')
        self._dsmax = lp.Variable('dsmax')

        self._vol = lp.Variable('vol')
        self._Cb = lp.Variable('Cb')

        self._lwl = lp.Variable('lwl')
        self._bwl = lp.Variable('bwl')

        self._Awp = lp.Variable('Awp')  #waterplane area
        self._Cwp = lp.Variable('Cwp')

        self._Amsh = lp.Variable(
            'Amsh')  #Area midship - area of largest midship section
        self._Cmidshp = lp.Variable('Cmidshp')  #midship coeff

        self._Cp = lp.Variable('Cp')

        s = lp.State(
            values={
                self._draft: None,
                self._dsmax: None,
                self._vol: None,
                self._Cb: None,
                self._lwl: None,
                self._bwl: None,
                self._Awp: None,
                self._Amsh: None,
                self._Cwp: None,
                self._Cmidshp: None,
                self._Cp: None
            })
        return s
        Cmidshp = self.Cmidshp
        Cp = self.Cp
        s = self.state

        print Cb, s.value_of(Cb)
        print Cmidshp, s.value_of(Cmidshp)
        goal = lp.Goal.divo(Cb, Cmidshp, Cp)
        s = goal(s)[0]
        s = block_coefficient(lwl, bwl, draft, vol, Cb, s)
        s = midship_coefficient(bwl, dsmax, Amsh, Cmidshp, s)

        return s

if __name__ == '__main__':

    draft = lp.Variable('draft')
    dsmax = lp.Variable('dsmax')

    vol = lp.Variable('vol')
    Cb = lp.Variable('Cb')

    lwl = lp.Variable('lwl')
    bwl = lp.Variable('bwl')

    Awp = lp.Variable('Awp')  #waterplane area
    Cwp = lp.Variable('Cwp')

    Amsh = lp.Variable('Amsh')  #Area midship - area of largest midship section
    Cmidshp = lp.Variable('Cmidshp')  #midship coeff

    Cp = lp.Variable('Cp')