Exemplo n.º 1
0
def test_pitch_range_clip():
    """Pitch in this time range goes from approximately 48.5 to 175.0 degrees.
    pftank2t.json is used as a placeholder to load a new thermal model, and
    should be able to be replaced with any other model. Make sure the pitch
    range stored in the model object does not get clipped to a narrower range.
    Make sure the pitch range stored does not include values outside of the 45
    to 180 degree range.

    Parameters
    ----------

    Returns
    -------

    """
    mdl = ThermalModel('tank', start='2019:120:12:00:00', stop='2019:122:12:00:00',
                       model_spec=abs_path('pftank2t.json'))

    mdl.comp['pf0tank2t'].set_data(20.0)
    mdl.make()
    mdl.calc()

    pitch = mdl.get_comp('pitch')
    assert np.any(pitch.mvals > 170)
    assert np.all((pitch.mvals > 45) & (pitch.mvals < 180))
Exemplo n.º 2
0
def test_multi_solar_heat_values():
    P_pitches = [45, 180]
    P_vals = [1.0, 1.0]
    P_pitches2 = [45, 65, 90, 140, 180]
    P_vals2 = [1.0, 1.0, 0.0, 1.0, 1.0]

    model = ThermalModel('test', start='2011:001', stop='2011:005')
    tephin = model.add(Node, 'tephin')
    tcylaft6 = model.add(Node, 'tcylaft6')
    pitch = model.add(Pitch)
    eclipse = model.add(Eclipse)

    model.add(HeatSink, tephin, T=0.0, tau=200.0)
    model.add(HeatSink, tcylaft6, T=0.0, tau=200.0)

    model.add(SolarHeat, tephin, pitch, eclipse, P_pitches, P_vals)
    model.add(SolarHeat, tcylaft6, pitch, eclipse, P_pitches2, P_vals2)

    tephin.set_data(30.0)
    tcylaft6.set_data(30.0)
    pitch.set_data(90.0)
    eclipse.set_data(False)

    model.make()
    model.calc()

    mvals = model.comp['tephin'].mvals
    mvals2 = model.comp['tcylaft6'].mvals
    assert len(mvals) == 1051
    assert mvals[0] == 30.0
    assert abs(mvals[500] - 157.4740) < 0.001
    assert abs(mvals[1050] - 196.4138) < 0.001

    assert len(mvals2) == 1051
    assert mvals2[0] == 30.0
    assert abs(mvals2[500] - 15.8338) < 0.001
    assert abs(mvals2[1050] - 11.4947) < 0.001

    # Make sure we can round-trip the model through a JSON file
    temp_name = tempfile.NamedTemporaryFile(delete=False).name
    model.write(temp_name)
    model2 = ThermalModel('test', model_spec=temp_name,
                          start='2011:001', stop='2011:005')
    os.unlink(temp_name)
    model2.get_comp('tephin').set_data(30.0)
    model2.get_comp('tcylaft6').set_data(30.0)
    model2.get_comp('pitch').set_data(90.0)
    model2.get_comp('eclipse').set_data(False)

    model2.make()
    model2.calc()

    mvals = model2.comp['tephin'].mvals
    mvals2 = model2.comp['tcylaft6'].mvals

    assert len(mvals) == 1051
    assert mvals[0] == 30.0
    assert abs(mvals[500] - 157.4740) < 0.001
    assert abs(mvals[1049] - 196.4138) < 0.001

    assert len(mvals2) == 1051
    assert mvals2[0] == 30.0
    assert abs(mvals2[500] - 15.8338) < 0.001
    assert abs(mvals2[1049] - 11.4947) < 0.001
Exemplo n.º 3
0
def test_multi_solar_heat_values():
    P_pitches = [45, 180]
    P_vals = [1.0, 1.0]
    P_pitches2 = [45, 65, 90, 140, 180]
    P_vals2 = [1.0, 1.0, 0.0, 1.0, 1.0]

    model = ThermalModel('test', start='2011:001:12:00:00', stop='2011:005:12:00:00')
    tephin = model.add(Node, 'tephin')
    tcylaft6 = model.add(Node, 'tcylaft6')
    pitch = model.add(Pitch)
    eclipse = model.add(Eclipse)

    model.add(HeatSink, tephin, T=0.0, tau=200.0)
    model.add(HeatSink, tcylaft6, T=0.0, tau=200.0)

    model.add(SolarHeat, tephin, pitch, eclipse, P_pitches, P_vals)
    model.add(SolarHeat, tcylaft6, pitch, eclipse, P_pitches2, P_vals2)

    tephin.set_data(30.0)
    tcylaft6.set_data(30.0)
    pitch.set_data(90.0)
    eclipse.set_data(False)

    model.make()
    model.calc()

    mvals = model.comp['tephin'].mvals
    mvals2 = model.comp['tcylaft6'].mvals
    assert len(mvals) == 1051
    assert mvals[0] == 30.0
    assert abs(mvals[500] - 157.4740) < 0.001
    assert abs(mvals[1050] - 196.4138) < 0.001

    assert len(mvals2) == 1051
    assert mvals2[0] == 30.0
    assert abs(mvals2[500] - 15.8338) < 0.001
    assert abs(mvals2[1050] - 11.4947) < 0.001

    # Make sure we can round-trip the model through a JSON file
    temp_name = tempfile.NamedTemporaryFile(delete=False).name
    model.write(temp_name)
    model2 = ThermalModel('test', model_spec=temp_name,
                          start='2011:001:12:00:00', stop='2011:005:12:00:00')
    os.unlink(temp_name)
    model2.get_comp('tephin').set_data(30.0)
    model2.get_comp('tcylaft6').set_data(30.0)
    model2.get_comp('pitch').set_data(90.0)
    model2.get_comp('eclipse').set_data(False)

    model2.make()
    model2.calc()

    mvals = model2.comp['tephin'].mvals
    mvals2 = model2.comp['tcylaft6'].mvals

    assert len(mvals) == 1051
    assert mvals[0] == 30.0
    assert abs(mvals[500] - 157.4740) < 0.001
    assert abs(mvals[1049] - 196.4138) < 0.001

    assert len(mvals2) == 1051
    assert mvals2[0] == 30.0
    assert abs(mvals2[500] - 15.8338) < 0.001
    assert abs(mvals2[1049] - 11.4947) < 0.001