Code Duplication    Length = 32-33 lines in 4 locations

tests/test_scripts/test_solph/test_tsam/test_storage_tsam_integration.py 1 location

@@ 170-202 (lines=33) @@
167
    assert flows["storage-electricity"][7] == 100
168
169
170
def test_soc():
171
    assert flows["storage-None"][0] == pytest.approx(init_soc)
172
    assert flows["storage-None"][1] == pytest.approx(
173
        (100 * 1 / 0.8) / (1 - 0.01)
174
        + (100 * 1 / 0.8) / (1 - 0.01) ** 2
175
        + (50 * 1 / 0.8) / (1 - 0.01) ** 3
176
        + (100 * 1 / 0.8) / (1 - 0.01) ** 4
177
        + (50 * 1 / 0.8) / (1 - 0.01) ** 5,
178
        abs=1e-2,
179
    )
180
    assert flows["storage-None"][2] == pytest.approx(
181
        (100 * 1 / 0.8) / (1 - 0.01)
182
        + (50 * 1 / 0.8) / (1 - 0.01) ** 2
183
        + (100 * 1 / 0.8) / (1 - 0.01) ** 3
184
        + (50 * 1 / 0.8) / (1 - 0.01) ** 4,
185
        abs=1e-2,
186
    )
187
    assert flows["storage-None"][3] == pytest.approx(
188
        (50 * 1 / 0.8) / (1 - 0.01)
189
        + (100 * 1 / 0.8) / (1 - 0.01) ** 2
190
        + (50 * 1 / 0.8) / (1 - 0.01) ** 3,
191
        abs=1e-2,
192
    )
193
    assert flows["storage-None"][4] == pytest.approx(
194
        (100 * 1 / 0.8) / (1 - 0.01) + (50 * 1 / 0.8) / (1 - 0.01) ** 2,
195
        abs=1e-2,
196
    )
197
    assert flows["storage-None"][5] == pytest.approx(
198
        (50 * 1 / 0.8) / (1 - 0.01), abs=1e-2
199
    )
200
    assert flows["storage-None"][6] == pytest.approx(0, abs=1e-2)
201
    assert flows["storage-None"][7] == pytest.approx(
202
        (init_soc + (100 * 1 / 0.8)) / 0.99
203
    )
204

tests/test_scripts/test_solph/test_tsam/test_storage_tsam_vs_original.py 1 location

@@ 155-187 (lines=33) @@
152
    assert flows["storage-electricity"][7] == 100
153
154
155
def test_soc():
156
    assert flows["storage-None"][0] == pytest.approx(init_soc)
157
    assert flows["storage-None"][1] == pytest.approx(
158
        (100 * 1 / 0.8) / (1 - 0.01)
159
        + (100 * 1 / 0.8) / (1 - 0.01) ** 2
160
        + (50 * 1 / 0.8) / (1 - 0.01) ** 3
161
        + (100 * 1 / 0.8) / (1 - 0.01) ** 4
162
        + (50 * 1 / 0.8) / (1 - 0.01) ** 5,
163
        abs=1e-2,
164
    )
165
    assert flows["storage-None"][2] == pytest.approx(
166
        (100 * 1 / 0.8) / (1 - 0.01)
167
        + (50 * 1 / 0.8) / (1 - 0.01) ** 2
168
        + (100 * 1 / 0.8) / (1 - 0.01) ** 3
169
        + (50 * 1 / 0.8) / (1 - 0.01) ** 4,
170
        abs=1e-2,
171
    )
172
    assert flows["storage-None"][3] == pytest.approx(
173
        (50 * 1 / 0.8) / (1 - 0.01)
174
        + (100 * 1 / 0.8) / (1 - 0.01) ** 2
175
        + (50 * 1 / 0.8) / (1 - 0.01) ** 3,
176
        abs=1e-2,
177
    )
178
    assert flows["storage-None"][4] == pytest.approx(
179
        (100 * 1 / 0.8) / (1 - 0.01) + (50 * 1 / 0.8) / (1 - 0.01) ** 2,
180
        abs=1e-2,
181
    )
182
    assert flows["storage-None"][5] == pytest.approx(
183
        (50 * 1 / 0.8) / (1 - 0.01), abs=1e-2
184
    )
185
    assert flows["storage-None"][6] == pytest.approx(0, abs=1e-2)
186
    assert flows["storage-None"][7] == pytest.approx(
187
        (init_soc + (100 * 1 / 0.8)) / 0.99
188
    )
189

tests/test_scripts/test_solph/test_tsam/test_storage_invest_tsam_integration.py 1 location

@@ 182-213 (lines=32) @@
179
    assert flows["storage-electricity"][7] == 100
180
181
182
def test_soc():
183
    assert flows["storage-None"][0] == pytest.approx(init_soc)
184
    assert flows["storage-None"][1] == pytest.approx(
185
        (100 * 1 / 0.8) / (1 - 0.01)
186
        + (100 * 1 / 0.8) / (1 - 0.01) ** 2
187
        + (50 * 1 / 0.8) / (1 - 0.01) ** 3
188
        + (100 * 1 / 0.8) / (1 - 0.01) ** 4
189
        + (50 * 1 / 0.8) / (1 - 0.01) ** 5,
190
        abs=1e-2,
191
    )
192
    assert flows["storage-None"][2] == pytest.approx(
193
        (100 * 1 / 0.8) / (1 - 0.01)
194
        + (50 * 1 / 0.8) / (1 - 0.01) ** 2
195
        + (100 * 1 / 0.8) / (1 - 0.01) ** 3
196
        + (50 * 1 / 0.8) / (1 - 0.01) ** 4,
197
        abs=1e-2,
198
    )
199
    assert flows["storage-None"][3] == pytest.approx(
200
        (50 * 1 / 0.8) / (1 - 0.01)
201
        + (100 * 1 / 0.8) / (1 - 0.01) ** 2
202
        + (50 * 1 / 0.8) / (1 - 0.01) ** 3,
203
        abs=1e-2,
204
    )
205
    assert flows["storage-None"][4] == pytest.approx(
206
        (100 * 1 / 0.8) / (1 - 0.01) + (50 * 1 / 0.8) / (1 - 0.01) ** 2,
207
        abs=1e-2,
208
    )
209
    assert flows["storage-None"][5] == pytest.approx(
210
        (50 * 1 / 0.8) / (1 - 0.01), abs=1e-2
211
    )
212
    assert flows["storage-None"][6] == pytest.approx(0, abs=1e-2)
213
    assert flows["storage-None"][7] == pytest.approx(first_input)
214

tests/test_scripts/test_solph/test_tsam/test_storage_invest_tsam_integration_without_mp.py 1 location

@@ 181-212 (lines=32) @@
178
    assert flows["storage-electricity"][7] == 100
179
180
181
def test_soc():
182
    assert flows["storage-None"][0] == pytest.approx(init_soc)
183
    assert flows["storage-None"][1] == pytest.approx(
184
        (100 * 1 / 0.8) / (1 - 0.01)
185
        + (100 * 1 / 0.8) / (1 - 0.01) ** 2
186
        + (50 * 1 / 0.8) / (1 - 0.01) ** 3
187
        + (100 * 1 / 0.8) / (1 - 0.01) ** 4
188
        + (50 * 1 / 0.8) / (1 - 0.01) ** 5,
189
        abs=1e-2,
190
    )
191
    assert flows["storage-None"][2] == pytest.approx(
192
        (100 * 1 / 0.8) / (1 - 0.01)
193
        + (50 * 1 / 0.8) / (1 - 0.01) ** 2
194
        + (100 * 1 / 0.8) / (1 - 0.01) ** 3
195
        + (50 * 1 / 0.8) / (1 - 0.01) ** 4,
196
        abs=1e-2,
197
    )
198
    assert flows["storage-None"][3] == pytest.approx(
199
        (50 * 1 / 0.8) / (1 - 0.01)
200
        + (100 * 1 / 0.8) / (1 - 0.01) ** 2
201
        + (50 * 1 / 0.8) / (1 - 0.01) ** 3,
202
        abs=1e-2,
203
    )
204
    assert flows["storage-None"][4] == pytest.approx(
205
        (100 * 1 / 0.8) / (1 - 0.01) + (50 * 1 / 0.8) / (1 - 0.01) ** 2,
206
        abs=1e-2,
207
    )
208
    assert flows["storage-None"][5] == pytest.approx(
209
        (50 * 1 / 0.8) / (1 - 0.01), abs=1e-2
210
    )
211
    assert flows["storage-None"][6] == pytest.approx(0, abs=1e-2)
212
    assert flows["storage-None"][7] == pytest.approx(first_input)
213