Ejemplo n.º 1
0
def compute(tws_val, twa_range):
    Keel1 = Keel(Cu=1.00, Cl=0.78, Span=1.90)
    Rudder1 = Rudder(Cu=0.48, Cl=0.22, Span=1.15)

    YD41 = Yacht(
        Name="YD41",
        Lwl=11.90,
        Vol=6.05,
        Bwl=3.18,
        Tc=0.4,
        WSA=28.20,
        Tmax=2.30,
        Amax=1.051,
        Mass=6500,
        Ff=1.5,
        Fa=1.5,
        Boa=4.2,
        Loa=12.5,
        App=[Keel1, Rudder1],
        Sails=[
            Main(P=16.60, E=5.60, Roach=0.1, BAD=1.0),
            Jib(I=16.20, J=5.10, LPG=5.40, HBI=1.8),
            Kite(area=150.0, vce=9.55),
        ],
    )

    vpp = VPP(Yacht=YD41)
    vpp.set_analysis(
        np.array([tws_val]) / KNOTS_TO_MPS, twa_range / np.pi * 180.0)
    vpp.run()

    res = np.empty([len(twa_range), 2])
    for i, twa in enumerate(twa_range):
        res[i, :] = [twa, max(vpp.store[0, :, 0][i], vpp.store[0, :, 3][i])]
    return res
Ejemplo n.º 2
0
def makevppresults():
    data = request.get_json()
    keel = Keel(Cu=data["keel"]["Cu"],
                Cl=data["keel"]["Cl"],
                Span=data["keel"]["Span"])
    rudder = Rudder(Cu=data["rudder"]["Cu"],
                    Cl=data["rudder"]["Cu"],
                    Span=data["rudder"]["Cu"])
    main = (Main(
        P=data["main"]["P"],
        E=data["main"]["E"],
        Roach=data["main"]["Roach"],
        BAD=data["main"]["BAD"],
    ), )
    jib = (Jib(
        I=data["jib"]["I"],
        J=data["jib"]["J"],
        LPG=data["jib"]["LPG"],
        HBI=data["jib"]["HBI"],
    ), )
    kite = (Kite(area=data["kite"]["area"], vce=data["kite"]["vce"]), )
    yacht = Yacht(
        Name=data["yacht"]["Name"],
        Lwl=data["yacht"]["Lwl"],
        Vol=data["yacht"]["Vol"],
        Bwl=data["yacht"]["Bwl"],
        Tc=data["yacht"]["Tc"],
        WSA=data["yacht"]["WSA"],
        Tmax=data["yacht"]["Tmax"],
        Amax=data["yacht"]["Amax"],
        Mass=data["yacht"]["Mass"],
        Ff=data["yacht"]["Ff"],
        Fa=data["yacht"]["Fa"],
        Boa=data["yacht"]["Boa"],
        Loa=data["yacht"]["Loa"],
        App=[keel, rudder],
        Sails=[
            Main(
                P=data["main"]["P"],
                E=data["main"]["E"],
                Roach=data["main"]["Roach"],
                BAD=data["main"]["BAD"],
            ),
            Jib(
                I=data["jib"]["I"],
                J=data["jib"]["J"],
                LPG=data["jib"]["LPG"],
                HBI=data["jib"]["HBI"],
            ),
            Kite(area=data["kite"]["area"], vce=data["kite"]["vce"]),
        ],
    )
    vpp = VPP(Yacht=yacht)
    vpp.set_analysis(
        tws_range=np.array(data["tws_range"]),
        twa_range=np.array(data["twa_range"]),
    )

    vpp.run(verbose=True)
    res = vpp.result(
    )  # compare this result to the result given by the request
    return jsonify(res)
Ejemplo n.º 3
0
YD41 = Yacht(Name="YD41",
             Lwl=11.90,
             Vol=6.05,
             Bwl=3.18,
             Tc=0.4,
             WSA=28.20,
             Tmax=2.30,
             Amax=1.051,
             Mass=6500,
             Ff=1.5,
             Fa=1.5,
             Boa=4.2,
             Loa=12.5,
             App=[
                 Keel(Cu=1.00, Cl=0.78, Span=1.90),
                 Rudder(Cu=0.48, Cl=0.22, Span=1.15),
             ],
             Sails=[
                 Main("MN1", P=16.60, E=5.60, Roach=0.1, BAD=1.0),
                 Jib("J1", I=16.20, J=5.10, LPG=5.40, HBI=1.8),
                 Kite("A2", area=150.0, vce=9.55)
             ])

vpp = VPP(Yacht=YD41)

vpp.set_analysis(tws_range=np.arange(4.0, 18.0, 4.0),
                 twa_range=np.linspace(30.0, 180.0, 34))

vpp.run(verbose=False)
vpp.polar(n=3, save=False)
vpp.SailChart(save=True)
Ejemplo n.º 4
0
def test_local_vpp_solution():
    """
    Return the dictionary produced by the VPP from an API call.
    
    Pass the list of parameters as a dictionary.
    
    Recieve the results as a dictionary.
    """
    Keel1 = Keel(Cu=1.00, Cl=0.78, Span=1.90)
    Rudder1 = Rudder(Cu=0.48, Cl=0.22, Span=1.15)

    YD41 = Yacht(
        Name="YD41",
        Lwl=11.90,
        Vol=6.05,
        Bwl=3.18,
        Tc=0.4,
        WSA=28.20,
        Tmax=2.30,
        Amax=1.051,
        Mass=6500,
        Ff=1.5,
        Fa=1.5,
        Boa=4.2,
        Loa=12.5,
        App=[Keel1, Rudder1],
        Sails=[
            Main(P=16.60, E=5.60, Roach=0.1, BAD=1.0),
            Jib(I=16.20, J=5.10, LPG=5.40, HBI=1.8),
            Kite(area=150.0, vce=9.55),
        ],
    )

    yacht = dict(
        {
            "Name": "YD41",
            "Lwl": 11.90,
            "Vol": 6.05,
            "Bwl": 3.18,
            "Tc": 0.4,
            "WSA": 28.20,
            "Tmax": 2.30,
            "Amax": 1.051,
            "Mass": 6500,
            "Ff": 1.5,
            "Fa": 1.5,
            "Boa": 4.2,
            "Loa": 12.5,
        }
    )
    keel = dict({"Cu": 1.00, "Cl": 0.78, "Span": 1.90})
    rudder = dict({"Cu": 0.48, "Cl": 0.22, "Span": 1.15})
    main = dict({"P": 16.60, "E": 5.60, "Roach": 0.1, "BAD": 1.0})
    jib = dict({"I": 16.20, "J": 5.10, "LPG": 5.40, "HBI": 1.8})
    kite = dict({"area": 150.0, "vce": 9.55})
    tws_range = np.array([10.0]).tolist()
    twa_range = [i for i in np.linspace(30.0, 180.0, 5)]
    d = {
        "name": yacht["Name"],
        "yacht": yacht,
        "keel": keel,
        "rudder": rudder,
        "main": main,
        "jib": jib,
        "kite": kite,
        "tws_range": tws_range,
        "twa_range": twa_range,
    }
    json_string = json.dumps(d)
    url = "http://0.0.0.0:5000/api/vpp/"
    headers = {"content-type": "application/json", "Accept-Charset": "UTF-8"}
    response = requests.post(url, data=json_string, headers=headers).json()

    vpp = VPP(Yacht=YD41)
    vpp.set_analysis(
        tws_range=np.array([10.0]), twa_range=np.linspace(30.0, 180.0, 5),
    )
    vpp.run(verbose=True)
    results = vpp.result()

    print(results["tws"] == response["tws"])
    print(results["twa"] == response["twa"])
    print(
        np.isclose(results["perf"], response["perf"], rtol=0.1)
    )  # the results aren't always repeatable beyond 0.1 d.p.