Exemplo n.º 1
0
def test_coords_ground_shadows():

    # Create base params
    params = {
        'axis_azimuth': 0,
        'n_pvrows': 2,
        'pvrow_height': 2.5,
        'pvrow_width': 2.,
        'gcr': 0.4,
        'cut': {0: {'front': 5}, 1: {'back': 3}}
    }

    # Timeseries parameters for testing
    solar_zenith = np.array([20., 45.])
    solar_azimuth = np.array([70., 200.])
    surface_tilt = np.array([10., 70.])
    surface_azimuth = np.array([90., 270.])

    # Plot simple ordered pv array
    ordered_pvarray = OrderedPVArray(**params)
    ordered_pvarray.fit(solar_zenith, solar_azimuth, surface_tilt,
                        surface_azimuth)

    expected_gnd_shadow_coords = [
        [([-1.89924929, 0.19163641], [0., 0.]),
         ([0.18914857, 1.51846431], [0., 0.])],
        [([3.10075071, 5.19163641], [0., 0.]),
         ([5.18914857, 6.51846431], [0., 0.])]
    ]
    gnd_shadow_coords = [shadow.coords.as_array
                         for shadow in ordered_pvarray.ts_ground.shadows]

    np.testing.assert_almost_equal(
        expected_gnd_shadow_coords, gnd_shadow_coords)
Exemplo n.º 2
0
def test_coords_cut_points():

    # Create base params
    params = {
        'axis_azimuth': 0,
        'n_pvrows': 2,
        'pvrow_height': 2.5,
        'pvrow_width': 2.,
        'gcr': 0.4,
        'cut': {0: {'front': 5}, 1: {'back': 3}}
    }

    # Timeseries parameters for testing
    solar_zenith = np.array([20., 45.])
    solar_azimuth = np.array([70., 200.])
    surface_tilt = np.array([10., 70.])
    surface_azimuth = np.array([90., 270.])

    # Plot simple ordered pv array
    ordered_pvarray = OrderedPVArray(**params)
    ordered_pvarray.fit(solar_zenith, solar_azimuth, surface_tilt,
                        surface_azimuth)

    expected_cut_point_coords = [
        [[14.17820455, -0.90992559], [0., 0.]],
        [[19.17820455, 4.09007441], [0., 0.]]]

    cut_pt_coords = [cut_point.as_array
                     for cut_point in
                     ordered_pvarray.ts_ground.cut_point_coords]
    np.testing.assert_almost_equal(
        expected_cut_point_coords, cut_pt_coords)
Exemplo n.º 3
0
def test_ts_view_factors():
    """Test calculation of timeseries view factors for center PV row"""
    # Create base params
    params = {
        'axis_azimuth': 0,
        'n_pvrows': 3,
        'pvrow_height': 1.5,
        'pvrow_width': 2.,
        'gcr': 0.7
    }

    # Timeseries parameters for testing
    solar_zenith = np.array([45., 60., 45., 60., 0.])
    solar_azimuth = np.array([90., 90., 270., 270., 90.])
    surface_tilt = np.array([40., 40., 40., 40., 0.])
    surface_azimuth = np.array([90., 270., 90., 270., 90.])

    # Plot simple ordered pv array
    pvarray = OrderedPVArray(**params)
    pvarray.fit(solar_zenith, solar_azimuth, surface_tilt,
                surface_azimuth)

    # Calculate view factors
    pvrow_idx = 1
    segment_idx = 0
    ts_pvrows = pvarray.ts_pvrows
    ts_ground = pvarray.ts_ground
    rotation_vec = pvarray.rotation_vec
    calculator = VFCalculator()
    ts_segment = ts_pvrows[pvrow_idx].back.list_segments[segment_idx]
    # Calculate view factors for segment
    view_factors_segment = calculator.get_vf_ts_pvrow_element(
        pvrow_idx, ts_segment, ts_pvrows, ts_ground, rotation_vec,
        pvarray.width)
    # Calculate view factors for segment's illum surface (should be identical)
    view_factors_illum = calculator.get_vf_ts_pvrow_element(
        pvrow_idx, ts_segment.illum.list_ts_surfaces[0], ts_pvrows, ts_ground,
        rotation_vec, pvarray.width)

    expected_vf_to_obstructed_shadows = np.array([
        [0.053677, -0., 0.04077, 0.392779, 0.089299],
        [0.44436, -0., 0.004818, 0.323486, 0.5],
        [0.231492, 0.170844, -0., 0.030375, 0.089299]])
    expected_vf_to_gnd_total = np.array(
        [0.752735, 0.752735, 0.752735, 0.752735, 1.])
    expected_vf_to_gnd_illum = np.array(
        [0.023205, 0.581891, 0.707147, 0.006094, 0.321402])
    expected_vf_to_pvrow_total = np.array(
        [0.176386, 0.176386, 0.176386, 0.176386, 0.])
    expected_vf_to_pvrow_shaded = np.array([0., 0., 0., 0.068506, 0.])
    expected_vf_to_sky = np.array(
        [0.070879, 0.070879, 0.070879, 0.070879, -0.])
    # Test that segment and segment's illum surface values are identical
    for k, _ in view_factors_segment.items():
        np.testing.assert_almost_equal(
            view_factors_illum[k], view_factors_segment[k], decimal=6)
    # Now test that values are always consistent
    view_factors = view_factors_segment
    np.testing.assert_almost_equal(expected_vf_to_obstructed_shadows,
                                   view_factors['to_each_gnd_shadow'],
                                   decimal=6)
    np.testing.assert_almost_equal(expected_vf_to_gnd_total,
                                   view_factors['to_gnd_total'],
                                   decimal=6)
    np.testing.assert_almost_equal(expected_vf_to_gnd_illum,
                                   view_factors['to_gnd_illum'],
                                   decimal=6)
    np.testing.assert_almost_equal(expected_vf_to_pvrow_total,
                                   view_factors['to_pvrow_total'],
                                   decimal=6)
    np.testing.assert_almost_equal(expected_vf_to_pvrow_shaded,
                                   view_factors['to_pvrow_shaded'],
                                   decimal=6)
    np.testing.assert_almost_equal(expected_vf_to_sky, view_factors['to_sky'],
                                   decimal=6)