From 43234fc333b29d5e899246a6da24c280e610bfd6 Mon Sep 17 00:00:00 2001 From: kurt-rhee Date: Sun, 12 May 2024 09:25:34 -0700 Subject: [PATCH 01/53] wrote a simple transformer efficiency model --- pvlib/transformer.py | 84 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 pvlib/transformer.py diff --git a/pvlib/transformer.py b/pvlib/transformer.py new file mode 100644 index 0000000000..1e25b5e14a --- /dev/null +++ b/pvlib/transformer.py @@ -0,0 +1,84 @@ +""" +This module contains functions for transformer modeling. + +Transformer models calculate AC power output at a different voltage from the voltage +at the AC input terminals. Model parameters should be passed as a single dict. + +""" + +import numpy as np +import pandas as pd + + +def simple_efficiency(input_power, no_load_loss, load_loss, kva_rating): + r''' + Calculate the energy at the output terminal of the transformer + after taking into account efficiency using a simple calculation. + + Parameters + ---------- + input_power : numeric + The power that is input into the transformer. [W] + + no_load_loss : numeric + The constant losses experienced by a transformer, even + when the transformer is not under load. [% from 0 to 1] + + load_loss: numeric + The load dependent losses experienced by the transformer. + [% from 0 to 1] + + Returns + ------- + output_power : numeric + AC power output. [W] + + + References + ---------- + .. [1] Central Station Engineers of the Westinghouse Electric Corporation, + "Electrical Transmission and Distribution Reference Book" 4th Edition. pg. 101. + + ''' + + full_load_loss = (no_load_loss + load_loss) * kva_rating + no_load_loss_power = no_load_loss * kva_rating + load_loss_power = full_load_loss - no_load_loss_power + loss_power = ( + 1 / + (2 * load_loss_power) * + ( + (kva_rating ** 2) + + (2 * load_loss_power * input_power) - + ( + kva_rating * np.sqrt( + (kva_rating ** 2) + + (4 * load_loss_power * (input_power - no_load_loss)) + ) + ) + ) + ) + + output_power = input_power - loss_power + + return output_power + + +if __name__ == '__main__': + + input_power = pd.Series([0, 100, 200, 300]) + no_load_loss = 0.01 + load_loss = 0.005 + kva_rating = 100 + + test = simple_efficiency( + input_power=input_power, + no_load_loss=no_load_loss, + load_loss=load_loss, + kva_rating=kva_rating + ) + + print(test) + + print('done') + From f18ef779ec8fe0453e89b6f33bf3b3dc60ca210a Mon Sep 17 00:00:00 2001 From: kurt-rhee Date: Fri, 17 May 2024 16:08:15 -0700 Subject: [PATCH 02/53] edited documentation to include latex, unsure if it will compile correctly in docs. --- pvlib/tests/test_transformer.py | 44 ++++++++++++ pvlib/transformer.py | 117 ++++++++++++++++++++++++-------- 2 files changed, 132 insertions(+), 29 deletions(-) create mode 100644 pvlib/tests/test_transformer.py diff --git a/pvlib/tests/test_transformer.py b/pvlib/tests/test_transformer.py new file mode 100644 index 0000000000..15bea3fc8b --- /dev/null +++ b/pvlib/tests/test_transformer.py @@ -0,0 +1,44 @@ +import numpy as np +import pandas as pd + +from numpy.testing import assert_allclose + +from pvlib import transformer + + +def test_simple_transformer(): + + # define test inputs + input_power = pd.Series([ + -800.0, + 436016.609823837, + 1511820.16603752, + 1580687.44677249, + 1616441.79660171 + ]) + no_load_loss_fraction = 0.002 + load_loss_fraction = 0.007 + transformer_rating = 2750000 + + # define expected test results + expected_output_power = pd.Series([ + -6300.10103234071, + 430045.854892526, + 1500588.39919874, + 1568921.77089526, + 1604389.62839879 + ]) + + # run test function with test inputs + calculated_output_power = transformer.simple_efficiency( + input_power=input_power, + no_load_loss_fraction=no_load_loss_fraction, + load_loss_fraction=load_loss_fraction, + transformer_rating=transformer_rating + ) + + # determine if expected results are obtained + assert_allclose(calculated_output_power, expected_output_power) + +if __name__ == '__main__': + test_simple_transformer() \ No newline at end of file diff --git a/pvlib/transformer.py b/pvlib/transformer.py index 1e25b5e14a..222b66337e 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -10,24 +10,64 @@ import pandas as pd -def simple_efficiency(input_power, no_load_loss, load_loss, kva_rating): +def simple_efficiency(input_power, no_load_loss_fraction, load_loss_fraction, transformer_rating): r''' Calculate the energy at the output terminal of the transformer after taking into account efficiency using a simple calculation. + The equation used in this function can be derived from the reference. + + First, assume that the load loss is proportional to the square of output power. + + .. math:: + L_{load}(P_{out}) = L_{load}(P_{out}) * P^2_{out} + L_{load}(P_{out}) = L_{full, load} * P^2_{out} + + Total loss is the variable load loss, plus a constant no-load loss: + + .. math:: + L_{total}(P_{out}) = L_{no, load} + L_{load}(P_{out}) + L_{total}(P_{out}) = L_{no, load} + L_{full, load} * P^2_{out} + + + Conservation of energy: + + .. math:: + P_{in} = P_{out} + L_{total}(P_{out}) + P_{in} = P_{out} + L_{no, load} + L_{full, load} * P^2_{out} + + Now use quadratic formula to solve for $P_{out}$ as a function of $P_in$. + + ..math:: + P_{out} = \frac{-b +- \sqrt{b^2 - 4ac}}{2a} + a = L_{full, load} + b = 1 + c = L_{no, load} - P_{in} + + Therefore: + + ..math:: + P_{out} = \frac{-1 +- \sqrt{1 - 4*L_{full, load}*L_{no, load} - P_{in}}}{2*L_{no, load} - P_{in}} + + Note that the positive root must be the correct one if the output power in positive. + + Parameters ---------- input_power : numeric The power that is input into the transformer. [W] - no_load_loss : numeric + no_load_loss_fraction : numeric The constant losses experienced by a transformer, even when the transformer is not under load. [% from 0 to 1] - load_loss: numeric + load_loss_fraction: numeric The load dependent losses experienced by the transformer. [% from 0 to 1] + transformer_rating: numeric + The nominal output power of the transformer. [VA] + Returns ------- output_power : numeric @@ -41,44 +81,63 @@ def simple_efficiency(input_power, no_load_loss, load_loss, kva_rating): ''' - full_load_loss = (no_load_loss + load_loss) * kva_rating - no_load_loss_power = no_load_loss * kva_rating - load_loss_power = full_load_loss - no_load_loss_power - loss_power = ( - 1 / - (2 * load_loss_power) * + # calculate the load loss in terms of VA instead of percent + loss_at_full_load = (no_load_loss_fraction + load_loss_fraction) * transformer_rating + no_load_loss = no_load_loss_fraction * transformer_rating + load_loss = loss_at_full_load - no_load_loss + + # calculate how much power is lost + combined_loss = ( + (1 / (2 * load_loss)) * ( - (kva_rating ** 2) + - (2 * load_loss_power * input_power) - - ( - kva_rating * np.sqrt( - (kva_rating ** 2) + - (4 * load_loss_power * (input_power - no_load_loss)) - ) - ) + (transformer_rating ** 2) + + (2 * load_loss * input_power) - + (transformer_rating * np.sqrt( + (transformer_rating ** 2) + + (4 * load_loss) * (input_power - no_load_loss) + )) ) ) - output_power = input_power - loss_power + + # calculate final output power given calculated losses + output_power = input_power - combined_loss return output_power if __name__ == '__main__': - input_power = pd.Series([0, 100, 200, 300]) - no_load_loss = 0.01 - load_loss = 0.005 - kva_rating = 100 - - test = simple_efficiency( + # define test inputs + input_power = pd.Series([ + -800.0, + 436016.609823837, + 1511820.16603752, + 1580687.44677249, + 1616441.79660171 + ]) + no_load_loss_fraction = 0.002 + load_loss_fraction = 0.007 + transformer_rating = 2750000 + + # define expected test results + expected_output_power = pd.Series([ + -6300.10103234071, + 430045.854892526, + 1500588.39919874, + 1568921.77089526, + 1604389.62839879 + ]) + + # run test function with test inputs + calculated_output_power = simple_efficiency( input_power=input_power, - no_load_loss=no_load_loss, - load_loss=load_loss, - kva_rating=kva_rating - ) + no_load_loss_fraction=no_load_loss_fraction, + load_loss_fraction=load_loss_fraction, + transformer_rating=transformer_rating + ) - print(test) + # print(calculated_output_power) print('done') From aafebe8b39f638a7a20cbae762e1526a7016a675 Mon Sep 17 00:00:00 2001 From: kurt-rhee Date: Fri, 17 May 2024 16:15:13 -0700 Subject: [PATCH 03/53] removed "if __main__" --- pvlib/tests/test_transformer.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pvlib/tests/test_transformer.py b/pvlib/tests/test_transformer.py index 15bea3fc8b..23e2e28d56 100644 --- a/pvlib/tests/test_transformer.py +++ b/pvlib/tests/test_transformer.py @@ -6,6 +6,7 @@ from pvlib import transformer + def test_simple_transformer(): # define test inputs @@ -38,7 +39,4 @@ def test_simple_transformer(): ) # determine if expected results are obtained - assert_allclose(calculated_output_power, expected_output_power) - -if __name__ == '__main__': - test_simple_transformer() \ No newline at end of file + assert_allclose(calculated_output_power, expected_output_power) \ No newline at end of file From ee4210ea56f831a0781306c61c589801fd22c7b2 Mon Sep 17 00:00:00 2001 From: kurt-rhee Date: Fri, 17 May 2024 16:15:32 -0700 Subject: [PATCH 04/53] removed "if __main__" --- pvlib/transformer.py | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index 222b66337e..fba4487c40 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -104,40 +104,3 @@ def simple_efficiency(input_power, no_load_loss_fraction, load_loss_fraction, tr output_power = input_power - combined_loss return output_power - - -if __name__ == '__main__': - - # define test inputs - input_power = pd.Series([ - -800.0, - 436016.609823837, - 1511820.16603752, - 1580687.44677249, - 1616441.79660171 - ]) - no_load_loss_fraction = 0.002 - load_loss_fraction = 0.007 - transformer_rating = 2750000 - - # define expected test results - expected_output_power = pd.Series([ - -6300.10103234071, - 430045.854892526, - 1500588.39919874, - 1568921.77089526, - 1604389.62839879 - ]) - - # run test function with test inputs - calculated_output_power = simple_efficiency( - input_power=input_power, - no_load_loss_fraction=no_load_loss_fraction, - load_loss_fraction=load_loss_fraction, - transformer_rating=transformer_rating - ) - - # print(calculated_output_power) - - print('done') - From f68807804c704cc6bca836c73c62a3b854c0e6a8 Mon Sep 17 00:00:00 2001 From: kurt-rhee Date: Fri, 17 May 2024 16:38:17 -0700 Subject: [PATCH 05/53] changed whatsnew rst --- docs/sphinx/source/whatsnew/v0.11.0.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/sphinx/source/whatsnew/v0.11.0.rst b/docs/sphinx/source/whatsnew/v0.11.0.rst index 7ea847a6d9..ad8706267f 100644 --- a/docs/sphinx/source/whatsnew/v0.11.0.rst +++ b/docs/sphinx/source/whatsnew/v0.11.0.rst @@ -15,7 +15,7 @@ Deprecations Enhancements ~~~~~~~~~~~~ - +* Added a simple transformer efficiency model Bug fixes ~~~~~~~~~ @@ -35,3 +35,4 @@ Requirements Contributors ~~~~~~~~~~~~ +* Kurt Rhee (:ghuser:`kurt-rhee`) From 907efd307e67f76b1369052e75194a2543dd93eb Mon Sep 17 00:00:00 2001 From: kurt-rhee Date: Mon, 20 May 2024 10:28:15 -0700 Subject: [PATCH 06/53] updated to be in compliance with Flake8 --- pvlib/tests/test_transformer.py | 10 ++++----- pvlib/transformer.py | 38 +++++++++++++++++++-------------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/pvlib/tests/test_transformer.py b/pvlib/tests/test_transformer.py index 23e2e28d56..eb935bd21a 100644 --- a/pvlib/tests/test_transformer.py +++ b/pvlib/tests/test_transformer.py @@ -1,4 +1,3 @@ -import numpy as np import pandas as pd from numpy.testing import assert_allclose @@ -6,7 +5,6 @@ from pvlib import transformer - def test_simple_transformer(): # define test inputs @@ -16,7 +14,7 @@ def test_simple_transformer(): 1511820.16603752, 1580687.44677249, 1616441.79660171 - ]) + ]) no_load_loss_fraction = 0.002 load_loss_fraction = 0.007 transformer_rating = 2750000 @@ -36,7 +34,7 @@ def test_simple_transformer(): no_load_loss_fraction=no_load_loss_fraction, load_loss_fraction=load_loss_fraction, transformer_rating=transformer_rating - ) - + ) + # determine if expected results are obtained - assert_allclose(calculated_output_power, expected_output_power) \ No newline at end of file + assert_allclose(calculated_output_power, expected_output_power) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index fba4487c40..7c98087dae 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -1,28 +1,30 @@ """ This module contains functions for transformer modeling. -Transformer models calculate AC power output at a different voltage from the voltage -at the AC input terminals. Model parameters should be passed as a single dict. - +Transformer models calculate AC power output at a different voltage from the +voltage at the AC input terminals. """ import numpy as np -import pandas as pd -def simple_efficiency(input_power, no_load_loss_fraction, load_loss_fraction, transformer_rating): +def simple_efficiency( + input_power, no_load_loss_fraction, load_loss_fraction, + transformer_rating +): r''' Calculate the energy at the output terminal of the transformer after taking into account efficiency using a simple calculation. The equation used in this function can be derived from the reference. - First, assume that the load loss is proportional to the square of output power. + First, assume that the load loss is proportional to the square of output + power. .. math:: L_{load}(P_{out}) = L_{load}(P_{out}) * P^2_{out} L_{load}(P_{out}) = L_{full, load} * P^2_{out} - + Total loss is the variable load loss, plus a constant no-load loss: .. math:: @@ -43,13 +45,15 @@ def simple_efficiency(input_power, no_load_loss_fraction, load_loss_fraction, tr a = L_{full, load} b = 1 c = L_{no, load} - P_{in} - + Therefore: - + ..math:: - P_{out} = \frac{-1 +- \sqrt{1 - 4*L_{full, load}*L_{no, load} - P_{in}}}{2*L_{no, load} - P_{in}} + P_{out} = \frac{-1 +- \sqrt{1 - 4*L_{full, load}*L_{no, load} - + P_{in}}}{2*L_{no, load} - P_{in}} - Note that the positive root must be the correct one if the output power in positive. + Note that the positive root must be the correct one if the output power in + positive. Parameters @@ -77,21 +81,24 @@ def simple_efficiency(input_power, no_load_loss_fraction, load_loss_fraction, tr References ---------- .. [1] Central Station Engineers of the Westinghouse Electric Corporation, - "Electrical Transmission and Distribution Reference Book" 4th Edition. pg. 101. + "Electrical Transmission and Distribution Reference Book" 4th Edition. + pg. 101. ''' # calculate the load loss in terms of VA instead of percent - loss_at_full_load = (no_load_loss_fraction + load_loss_fraction) * transformer_rating + loss_at_full_load = ( + (no_load_loss_fraction + load_loss_fraction) * transformer_rating + ) no_load_loss = no_load_loss_fraction * transformer_rating load_loss = loss_at_full_load - no_load_loss # calculate how much power is lost combined_loss = ( - (1 / (2 * load_loss)) * + (1 / (2 * load_loss)) * ( (transformer_rating ** 2) + - (2 * load_loss * input_power) - + (2 * load_loss * input_power) - (transformer_rating * np.sqrt( (transformer_rating ** 2) + (4 * load_loss) * (input_power - no_load_loss) @@ -99,7 +106,6 @@ def simple_efficiency(input_power, no_load_loss_fraction, load_loss_fraction, tr ) ) - # calculate final output power given calculated losses output_power = input_power - combined_loss From a80bd7fa9c3577ca715a50aba0b3ad04442bd9e6 Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Mon, 20 May 2024 11:34:58 -0700 Subject: [PATCH 07/53] Update pvlib/transformer.py Co-authored-by: Cliff Hansen --- pvlib/transformer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index 7c98087dae..4357846c99 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -52,7 +52,7 @@ def simple_efficiency( P_{out} = \frac{-1 +- \sqrt{1 - 4*L_{full, load}*L_{no, load} - P_{in}}}{2*L_{no, load} - P_{in}} - Note that the positive root must be the correct one if the output power in + Note that the positive root must be the correct one if the output power is positive. From 107205347cefa18c723b108df40811fec14cf5d9 Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Mon, 20 May 2024 11:35:05 -0700 Subject: [PATCH 08/53] Update pvlib/transformer.py Co-authored-by: Cliff Hansen --- pvlib/transformer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index 4357846c99..8c2e5d92bd 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -59,7 +59,7 @@ def simple_efficiency( Parameters ---------- input_power : numeric - The power that is input into the transformer. [W] + The real power input to the transformer. [W] no_load_loss_fraction : numeric The constant losses experienced by a transformer, even From d8381fee827337aba491f3da8de1904f06a61309 Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Mon, 20 May 2024 11:35:13 -0700 Subject: [PATCH 09/53] Update pvlib/transformer.py Co-authored-by: Cliff Hansen --- pvlib/transformer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index 8c2e5d92bd..ece00829e0 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -75,7 +75,7 @@ def simple_efficiency( Returns ------- output_power : numeric - AC power output. [W] + Real power output. [W] References From 349604f20f9ed89f5c1a76578bb1b78779b93b2d Mon Sep 17 00:00:00 2001 From: kurt-rhee Date: Mon, 20 May 2024 14:25:41 -0700 Subject: [PATCH 10/53] + added transformer to index.rst + added transformer.rst to pvlib/docs/source/sphinx/reference --- docs/sphinx/source/reference/index.rst | 1 + docs/sphinx/source/reference/transformer.rst | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 docs/sphinx/source/reference/transformer.rst diff --git a/docs/sphinx/source/reference/index.rst b/docs/sphinx/source/reference/index.rst index 9083f85bdd..8a990ac923 100644 --- a/docs/sphinx/source/reference/index.rst +++ b/docs/sphinx/source/reference/index.rst @@ -20,3 +20,4 @@ API reference bifacial scaling location + transformer diff --git a/docs/sphinx/source/reference/transformer.rst b/docs/sphinx/source/reference/transformer.rst new file mode 100644 index 0000000000..0f558fbf30 --- /dev/null +++ b/docs/sphinx/source/reference/transformer.rst @@ -0,0 +1,11 @@ +.. currentmodule:: pvlib + +Scaling +======= + +Methods for calculate losses in transformer equipment + +.. autosummary:: + :toctree: generated/ + + transformer.simple_efficiency From af637600277bb6eb511c6f2d9aad4e8c3ae1005d Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Mon, 20 May 2024 15:16:28 -0700 Subject: [PATCH 11/53] Update docs/sphinx/source/reference/transformer.rst Co-authored-by: Cliff Hansen --- docs/sphinx/source/reference/transformer.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/sphinx/source/reference/transformer.rst b/docs/sphinx/source/reference/transformer.rst index 0f558fbf30..c16137381d 100644 --- a/docs/sphinx/source/reference/transformer.rst +++ b/docs/sphinx/source/reference/transformer.rst @@ -1,7 +1,7 @@ .. currentmodule:: pvlib -Scaling -======= +Transformer losses +================== Methods for calculate losses in transformer equipment From 3bb136412a6cd66e5fea68230e834b1b2c18d4e9 Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Mon, 20 May 2024 15:17:23 -0700 Subject: [PATCH 12/53] Update pvlib/transformer.py Co-authored-by: Cliff Hansen --- pvlib/transformer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index ece00829e0..6aee7c4379 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -81,8 +81,8 @@ def simple_efficiency( References ---------- .. [1] Central Station Engineers of the Westinghouse Electric Corporation, - "Electrical Transmission and Distribution Reference Book" 4th Edition. - pg. 101. + "Electrical Transmission and Distribution Reference Book" 4th Edition. + pg. 101. ''' From 1571fdda784f564595a75edfa977ba05e81cdd01 Mon Sep 17 00:00:00 2001 From: kurt-rhee Date: Mon, 20 May 2024 15:20:20 -0700 Subject: [PATCH 13/53] updated names of loss values and changed to [unitless] --- pvlib/transformer.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index 6aee7c4379..ff465fe168 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -9,8 +9,7 @@ def simple_efficiency( - input_power, no_load_loss_fraction, load_loss_fraction, - transformer_rating + input_power, no_load_loss, load_loss, transformer_rating ): r''' Calculate the energy at the output terminal of the transformer @@ -61,13 +60,13 @@ def simple_efficiency( input_power : numeric The real power input to the transformer. [W] - no_load_loss_fraction : numeric + no_load_loss : numeric The constant losses experienced by a transformer, even - when the transformer is not under load. [% from 0 to 1] + when the transformer is not under load. Value from 0 to 1. [Unitless] - load_loss_fraction: numeric + load_loss: numeric The load dependent losses experienced by the transformer. - [% from 0 to 1] + Value from 0 to 1. [Unitless] transformer_rating: numeric The nominal output power of the transformer. [VA] @@ -88,9 +87,9 @@ def simple_efficiency( # calculate the load loss in terms of VA instead of percent loss_at_full_load = ( - (no_load_loss_fraction + load_loss_fraction) * transformer_rating + (no_load_loss + load_loss) * transformer_rating ) - no_load_loss = no_load_loss_fraction * transformer_rating + no_load_loss = no_load_loss * transformer_rating load_loss = loss_at_full_load - no_load_loss # calculate how much power is lost From 77efdde5d64296fe8b053a3650e98a22dd71ed02 Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Mon, 20 May 2024 15:21:43 -0700 Subject: [PATCH 14/53] Update pvlib/transformer.py Co-authored-by: Cliff Hansen --- pvlib/transformer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index ff465fe168..e969176123 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -13,7 +13,7 @@ def simple_efficiency( ): r''' Calculate the energy at the output terminal of the transformer - after taking into account efficiency using a simple calculation. + after taking into account efficiency using a simple calculation. The equation used in this function can be derived from the reference. From b029b9ebbf80a684683887ba4bd2a3dc8ff091ff Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Mon, 20 May 2024 15:22:00 -0700 Subject: [PATCH 15/53] Update pvlib/transformer.py Co-authored-by: Cliff Hansen --- pvlib/transformer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index e969176123..4e2d7c320f 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -15,7 +15,7 @@ def simple_efficiency( Calculate the energy at the output terminal of the transformer after taking into account efficiency using a simple calculation. - The equation used in this function can be derived from the reference. + The equation used in this function can be derived from [1]_. First, assume that the load loss is proportional to the square of output power. From 06efabefc63a478e6634a1c3ec80c5a667da2389 Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Mon, 20 May 2024 15:22:14 -0700 Subject: [PATCH 16/53] Update pvlib/transformer.py Co-authored-by: Cliff Hansen --- pvlib/transformer.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index 4e2d7c320f..2548338095 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -27,8 +27,9 @@ def simple_efficiency( Total loss is the variable load loss, plus a constant no-load loss: .. math:: - L_{total}(P_{out}) = L_{no, load} + L_{load}(P_{out}) - L_{total}(P_{out}) = L_{no, load} + L_{full, load} * P^2_{out} + + L_{total}(P_{out}) = L_{no, load} + L_{load}(P_{out}) + L_{total}(P_{out}) = L_{no, load} + L_{full, load} * P^2_{out} Conservation of energy: From 9361419d82dce522e5ea8ece7a53037618ad922c Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Mon, 20 May 2024 15:22:26 -0700 Subject: [PATCH 17/53] Update pvlib/transformer.py Co-authored-by: Cliff Hansen --- pvlib/transformer.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index 2548338095..fdf3e6128a 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -35,8 +35,9 @@ def simple_efficiency( Conservation of energy: .. math:: - P_{in} = P_{out} + L_{total}(P_{out}) - P_{in} = P_{out} + L_{no, load} + L_{full, load} * P^2_{out} + + P_{in} = P_{out} + L_{total}(P_{out}) + P_{in} = P_{out} + L_{no, load} + L_{full, load} * P^2_{out} Now use quadratic formula to solve for $P_{out}$ as a function of $P_in$. From aeeb23b0889eff9baa2d168fa39352f2a3b8cdb6 Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Mon, 20 May 2024 15:22:35 -0700 Subject: [PATCH 18/53] Update pvlib/transformer.py Co-authored-by: Cliff Hansen --- pvlib/transformer.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index fdf3e6128a..7e33c9df95 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -42,10 +42,11 @@ def simple_efficiency( Now use quadratic formula to solve for $P_{out}$ as a function of $P_in$. ..math:: - P_{out} = \frac{-b +- \sqrt{b^2 - 4ac}}{2a} - a = L_{full, load} - b = 1 - c = L_{no, load} - P_{in} + + P_{out} = \frac{-b +- \sqrt{b^2 - 4ac}}{2a} + a = L_{full, load} + b = 1 + c = L_{no, load} - P_{in} Therefore: From 3e0751c044505ca3b45e835b2b876cd6b9f46002 Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Mon, 20 May 2024 15:22:43 -0700 Subject: [PATCH 19/53] Update pvlib/transformer.py Co-authored-by: Cliff Hansen --- pvlib/transformer.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index 7e33c9df95..d9fa6aa6fc 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -51,8 +51,9 @@ def simple_efficiency( Therefore: ..math:: - P_{out} = \frac{-1 +- \sqrt{1 - 4*L_{full, load}*L_{no, load} - - P_{in}}}{2*L_{no, load} - P_{in}} + + P_{out} = \frac{-1 +- \sqrt{1 - 4*L_{full, load}*L_{no, load} - + P_{in}}}{2*L_{no, load} - P_{in}} Note that the positive root must be the correct one if the output power is positive. From 0b18c4361b98119e8ed4eff99241c53ed1a7db1a Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Mon, 20 May 2024 15:45:02 -0700 Subject: [PATCH 20/53] Update pvlib/transformer.py Co-authored-by: Cliff Hansen --- pvlib/transformer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index d9fa6aa6fc..1c380fd59c 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -66,7 +66,8 @@ def simple_efficiency( no_load_loss : numeric The constant losses experienced by a transformer, even - when the transformer is not under load. Value from 0 to 1. [Unitless] + when the transformer is not under load. Fraction of transformer rating, + value from 0 to 1. [unitless] load_loss: numeric The load dependent losses experienced by the transformer. From 8ab1001779aa329d7fa24952c93c01ed74597e28 Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Mon, 20 May 2024 15:45:10 -0700 Subject: [PATCH 21/53] Update pvlib/transformer.py Co-authored-by: Cliff Hansen --- pvlib/transformer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index 1c380fd59c..ab72fe5bef 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -71,7 +71,7 @@ def simple_efficiency( load_loss: numeric The load dependent losses experienced by the transformer. - Value from 0 to 1. [Unitless] + Fraction of transformer rating, value from 0 to 1. [unitless] transformer_rating: numeric The nominal output power of the transformer. [VA] From aa31498f3534331bf151777e08f1390ae209bf15 Mon Sep 17 00:00:00 2001 From: kurt-rhee Date: Mon, 20 May 2024 15:47:25 -0700 Subject: [PATCH 22/53] forgot to update arguments in test function --- pvlib/tests/test_transformer.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pvlib/tests/test_transformer.py b/pvlib/tests/test_transformer.py index eb935bd21a..a286d3994d 100644 --- a/pvlib/tests/test_transformer.py +++ b/pvlib/tests/test_transformer.py @@ -15,8 +15,8 @@ def test_simple_transformer(): 1580687.44677249, 1616441.79660171 ]) - no_load_loss_fraction = 0.002 - load_loss_fraction = 0.007 + no_load_loss = 0.002 + load_loss = 0.007 transformer_rating = 2750000 # define expected test results @@ -31,8 +31,8 @@ def test_simple_transformer(): # run test function with test inputs calculated_output_power = transformer.simple_efficiency( input_power=input_power, - no_load_loss_fraction=no_load_loss_fraction, - load_loss_fraction=load_loss_fraction, + no_load_loss=no_load_loss, + load_loss=load_loss, transformer_rating=transformer_rating ) From 865bfdf527fe773d3c1acb78d77f1f087377aa8a Mon Sep 17 00:00:00 2001 From: kurt-rhee Date: Mon, 20 May 2024 15:53:39 -0700 Subject: [PATCH 23/53] updated formatting of docstring --- pvlib/transformer.py | 57 +++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index ab72fe5bef..46cab492e4 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -17,12 +17,38 @@ def simple_efficiency( The equation used in this function can be derived from [1]_. + + Parameters + ---------- + input_power : numeric + The real power input to the transformer. [W] + + no_load_loss : numeric + The constant losses experienced by a transformer, even + when the transformer is not under load. Fraction of transformer rating, + value from 0 to 1. [unitless] + + load_loss: numeric + The load dependent losses experienced by the transformer. + Fraction of transformer rating, value from 0 to 1. [unitless] + + transformer_rating: numeric + The nominal output power of the transformer. [VA] + + Returns + ------- + output_power : numeric + Real power output. [W] + + Notes + ------- First, assume that the load loss is proportional to the square of output power. .. math:: - L_{load}(P_{out}) = L_{load}(P_{out}) * P^2_{out} - L_{load}(P_{out}) = L_{full, load} * P^2_{out} + + L_{load}(P_{out}) = L_{load}(P_{out}) * P^2_{out} + L_{load}(P_{out}) = L_{full, load} * P^2_{out} Total loss is the variable load loss, plus a constant no-load loss: @@ -41,7 +67,7 @@ def simple_efficiency( Now use quadratic formula to solve for $P_{out}$ as a function of $P_in$. - ..math:: + .. math:: P_{out} = \frac{-b +- \sqrt{b^2 - 4ac}}{2a} a = L_{full, load} @@ -50,7 +76,7 @@ def simple_efficiency( Therefore: - ..math:: + .. math:: P_{out} = \frac{-1 +- \sqrt{1 - 4*L_{full, load}*L_{no, load} - P_{in}}}{2*L_{no, load} - P_{in}} @@ -59,29 +85,6 @@ def simple_efficiency( positive. - Parameters - ---------- - input_power : numeric - The real power input to the transformer. [W] - - no_load_loss : numeric - The constant losses experienced by a transformer, even - when the transformer is not under load. Fraction of transformer rating, - value from 0 to 1. [unitless] - - load_loss: numeric - The load dependent losses experienced by the transformer. - Fraction of transformer rating, value from 0 to 1. [unitless] - - transformer_rating: numeric - The nominal output power of the transformer. [VA] - - Returns - ------- - output_power : numeric - Real power output. [W] - - References ---------- .. [1] Central Station Engineers of the Westinghouse Electric Corporation, From eb70aeb978aafde2347244c8915bd016838b4fbd Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Tue, 21 May 2024 08:48:08 -0700 Subject: [PATCH 24/53] Update pvlib/transformer.py Co-authored-by: Cliff Hansen --- pvlib/transformer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index 46cab492e4..1adf414a30 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -65,7 +65,7 @@ def simple_efficiency( P_{in} = P_{out} + L_{total}(P_{out}) P_{in} = P_{out} + L_{no, load} + L_{full, load} * P^2_{out} - Now use quadratic formula to solve for $P_{out}$ as a function of $P_in$. + Now use quadratic formula to solve for :math:`P_{out}` as a function of :math:`P_in`. .. math:: From 35f122fb973844c18c50c39f2d897a92a034d1fe Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Tue, 21 May 2024 08:48:30 -0700 Subject: [PATCH 25/53] Update pvlib/transformer.py Co-authored-by: Cliff Hansen --- pvlib/transformer.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index 1adf414a30..25bc807415 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -47,8 +47,9 @@ def simple_efficiency( .. math:: - L_{load}(P_{out}) = L_{load}(P_{out}) * P^2_{out} - L_{load}(P_{out}) = L_{full, load} * P^2_{out} + L_{load}(P_{out}) = L_{load}(P_{out}) \times P^2_{out} + + L_{load}(P_{out}) = L_{full, load} \times P^2_{out} Total loss is the variable load loss, plus a constant no-load loss: From 5592bc2dd7d84eded6449b8510427c42c52ebfa0 Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Tue, 21 May 2024 08:48:44 -0700 Subject: [PATCH 26/53] Update pvlib/transformer.py Co-authored-by: Cliff Hansen --- pvlib/transformer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index 25bc807415..fde12c0f81 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -56,7 +56,8 @@ def simple_efficiency( .. math:: L_{total}(P_{out}) = L_{no, load} + L_{load}(P_{out}) - L_{total}(P_{out}) = L_{no, load} + L_{full, load} * P^2_{out} + + L_{total}(P_{out}) = L_{no, load} + L_{full, load} \times P^2_{out} Conservation of energy: From 63649c823169885131b4371bb283cdbc54e4c843 Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Tue, 21 May 2024 08:48:52 -0700 Subject: [PATCH 27/53] Update pvlib/transformer.py Co-authored-by: Cliff Hansen --- pvlib/transformer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index fde12c0f81..8bd8f2811b 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -65,7 +65,8 @@ def simple_efficiency( .. math:: P_{in} = P_{out} + L_{total}(P_{out}) - P_{in} = P_{out} + L_{no, load} + L_{full, load} * P^2_{out} + + P_{in} = P_{out} + L_{no, load} + L_{full, load} \times P^2_{out} Now use quadratic formula to solve for :math:`P_{out}` as a function of :math:`P_in`. From d49fee5e3a69d5476ee010d049785369697bd33e Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Tue, 21 May 2024 08:49:00 -0700 Subject: [PATCH 28/53] Update pvlib/transformer.py Co-authored-by: Cliff Hansen --- pvlib/transformer.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index 8bd8f2811b..cc125fbebd 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -81,8 +81,9 @@ def simple_efficiency( .. math:: - P_{out} = \frac{-1 +- \sqrt{1 - 4*L_{full, load}*L_{no, load} - - P_{in}}}{2*L_{no, load} - P_{in}} + P_{out} = \frac{-1 +- \sqrt{1 - 4 L_{full, load} \times L_{no, load} - + + P_{in}}}{2 L_{no, load} - P_{in}} Note that the positive root must be the correct one if the output power is positive. From 75394029e98b318fac0b8197d2bcf149561a8495 Mon Sep 17 00:00:00 2001 From: kurt-rhee Date: Tue, 21 May 2024 08:50:01 -0700 Subject: [PATCH 29/53] adding space between equations in docstring --- pvlib/transformer.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index cc125fbebd..a09c9f746b 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -73,8 +73,11 @@ def simple_efficiency( .. math:: P_{out} = \frac{-b +- \sqrt{b^2 - 4ac}}{2a} + a = L_{full, load} + b = 1 + c = L_{no, load} - P_{in} Therefore: From d5a862c79e177053ea64d30de5d3b7c3e21f45fd Mon Sep 17 00:00:00 2001 From: kurt-rhee Date: Tue, 21 May 2024 09:23:27 -0700 Subject: [PATCH 30/53] fixing flake8 linting --- pvlib/transformer.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index a09c9f746b..c7adc359e4 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -68,7 +68,8 @@ def simple_efficiency( P_{in} = P_{out} + L_{no, load} + L_{full, load} \times P^2_{out} - Now use quadratic formula to solve for :math:`P_{out}` as a function of :math:`P_in`. + Now use quadratic formula to solve for :math:`P_{out}` as a function of + :math:`P_in`. .. math:: @@ -84,9 +85,9 @@ def simple_efficiency( .. math:: - P_{out} = \frac{-1 +- \sqrt{1 - 4 L_{full, load} \times L_{no, load} - - - P_{in}}}{2 L_{no, load} - P_{in}} + P_{out} = \frac{-1 +- \sqrt{1 - 4 L_{full, load} + + \times L_{no, load} - P_{in}}}{2 L_{no, load} - P_{in}} Note that the positive root must be the correct one if the output power is positive. From 9fe05f85af3a595897ed4f6d6e8b7ca1fbdfc618 Mon Sep 17 00:00:00 2001 From: kurt-rhee Date: Tue, 21 May 2024 09:45:32 -0700 Subject: [PATCH 31/53] removing whitespace --- pvlib/transformer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index c7adc359e4..c75980ad68 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -78,7 +78,7 @@ def simple_efficiency( a = L_{full, load} b = 1 - + c = L_{no, load} - P_{in} Therefore: @@ -86,7 +86,7 @@ def simple_efficiency( .. math:: P_{out} = \frac{-1 +- \sqrt{1 - 4 L_{full, load} - + \times L_{no, load} - P_{in}}}{2 L_{no, load} - P_{in}} Note that the positive root must be the correct one if the output power is From 99ab409ea7789011a24e9538f073e7dccc3ea22d Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Tue, 21 May 2024 15:56:46 -0700 Subject: [PATCH 32/53] Update docs/sphinx/source/reference/transformer.rst Co-authored-by: Echedey Luis <80125792+echedey-ls@users.noreply.github.com> --- docs/sphinx/source/reference/transformer.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sphinx/source/reference/transformer.rst b/docs/sphinx/source/reference/transformer.rst index c16137381d..293f301296 100644 --- a/docs/sphinx/source/reference/transformer.rst +++ b/docs/sphinx/source/reference/transformer.rst @@ -3,7 +3,7 @@ Transformer losses ================== -Methods for calculate losses in transformer equipment +Methods to account for losses in transformers .. autosummary:: :toctree: generated/ From feb2c30e5637f63c8396a573f96bc209c067d553 Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Tue, 21 May 2024 15:57:08 -0700 Subject: [PATCH 33/53] Update pvlib/transformer.py Co-authored-by: Echedey Luis <80125792+echedey-ls@users.noreply.github.com> --- pvlib/transformer.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index c75980ad68..81b119ba55 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -1,8 +1,7 @@ """ This module contains functions for transformer modeling. -Transformer models calculate AC power output at a different voltage from the -voltage at the AC input terminals. +Transformer models calculate AC power output and losses at a given input power. """ import numpy as np From e1522bec74d97943236947a0c92665ee704ab558 Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Tue, 21 May 2024 15:57:20 -0700 Subject: [PATCH 34/53] Update pvlib/transformer.py Co-authored-by: Cliff Hansen --- pvlib/transformer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index 81b119ba55..347da2f81d 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -68,7 +68,7 @@ def simple_efficiency( P_{in} = P_{out} + L_{no, load} + L_{full, load} \times P^2_{out} Now use quadratic formula to solve for :math:`P_{out}` as a function of - :math:`P_in`. + :math:`P_{in}`. .. math:: From ae378c9ad3a3f6145bea5ea920f5246cee41bbb7 Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Tue, 21 May 2024 15:57:38 -0700 Subject: [PATCH 35/53] Update pvlib/transformer.py Co-authored-by: Echedey Luis <80125792+echedey-ls@users.noreply.github.com> --- pvlib/transformer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index 347da2f81d..34c6254d4b 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -44,11 +44,11 @@ def simple_efficiency( First, assume that the load loss is proportional to the square of output power. - .. math:: + .. math:: - L_{load}(P_{out}) = L_{load}(P_{out}) \times P^2_{out} + L_{load}(P_{out}) &= L_{load}(P_{out}) \times P^2_{out} - L_{load}(P_{out}) = L_{full, load} \times P^2_{out} + L_{load}(P_{out}) &= L_{full, load} \times P^2_{out} Total loss is the variable load loss, plus a constant no-load loss: From 84ddbf255b9c7d66bd59d4a17560c8dc464be8c5 Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Tue, 21 May 2024 15:57:48 -0700 Subject: [PATCH 36/53] Update pvlib/transformer.py Co-authored-by: Echedey Luis <80125792+echedey-ls@users.noreply.github.com> --- pvlib/transformer.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index 34c6254d4b..3994ac2f9a 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -70,15 +70,15 @@ def simple_efficiency( Now use quadratic formula to solve for :math:`P_{out}` as a function of :math:`P_{in}`. - .. math:: + .. math:: - P_{out} = \frac{-b +- \sqrt{b^2 - 4ac}}{2a} + P_{out} &= \frac{-b +- \sqrt{b^2 - 4ac}}{2a} - a = L_{full, load} + a &= L_{full, load} - b = 1 + b &= 1 - c = L_{no, load} - P_{in} + c &= L_{no, load} - P_{in} Therefore: From 9a7dbc61fa74161b1ff56c519c30857db39273dd Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Tue, 21 May 2024 15:58:02 -0700 Subject: [PATCH 37/53] Update pvlib/transformer.py Co-authored-by: Echedey Luis <80125792+echedey-ls@users.noreply.github.com> --- pvlib/transformer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index 3994ac2f9a..a260751366 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -82,11 +82,11 @@ def simple_efficiency( Therefore: - .. math:: + .. math:: - P_{out} = \frac{-1 +- \sqrt{1 - 4 L_{full, load} + P_{out} = \frac{-1 \pm \sqrt{1 - 4 L_{full, load} - \times L_{no, load} - P_{in}}}{2 L_{no, load} - P_{in}} + \times L_{no, load} - P_{in}}}{2 L_{no, load} - P_{in}} Note that the positive root must be the correct one if the output power is positive. From 288161be313a5ed5c61d4fc703974de71028abd2 Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Tue, 21 May 2024 15:58:11 -0700 Subject: [PATCH 38/53] Update docs/sphinx/source/whatsnew/v0.11.0.rst Co-authored-by: Echedey Luis <80125792+echedey-ls@users.noreply.github.com> --- docs/sphinx/source/whatsnew/v0.11.0.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/sphinx/source/whatsnew/v0.11.0.rst b/docs/sphinx/source/whatsnew/v0.11.0.rst index ad8706267f..cac7681181 100644 --- a/docs/sphinx/source/whatsnew/v0.11.0.rst +++ b/docs/sphinx/source/whatsnew/v0.11.0.rst @@ -15,7 +15,9 @@ Deprecations Enhancements ~~~~~~~~~~~~ -* Added a simple transformer efficiency model +* Add a simple transformer efficiency model :py:func:`pvlib.transformer.simple_efficiency` + (:issue:`1269`, :pull:`2053`) + Bug fixes ~~~~~~~~~ From d080cc031e665908bcc72fd22f2e36e381efa9ee Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Tue, 21 May 2024 15:58:22 -0700 Subject: [PATCH 39/53] Update pvlib/transformer.py Co-authored-by: Echedey Luis <80125792+echedey-ls@users.noreply.github.com> --- pvlib/transformer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index a260751366..37c4092527 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -61,11 +61,11 @@ def simple_efficiency( Conservation of energy: - .. math:: + .. math:: - P_{in} = P_{out} + L_{total}(P_{out}) + P_{in} &= P_{out} + L_{total}(P_{out}) - P_{in} = P_{out} + L_{no, load} + L_{full, load} \times P^2_{out} + P_{in} &= P_{out} + L_{no, load} + L_{full, load} \times P^2_{out} Now use quadratic formula to solve for :math:`P_{out}` as a function of :math:`P_{in}`. From 53934ec717ddf0afd4cd9ae359a0afd311529fc4 Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Tue, 21 May 2024 16:01:43 -0700 Subject: [PATCH 40/53] Update pvlib/tests/test_transformer.py Co-authored-by: Echedey Luis <80125792+echedey-ls@users.noreply.github.com> --- pvlib/tests/test_transformer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/tests/test_transformer.py b/pvlib/tests/test_transformer.py index a286d3994d..60f884c280 100644 --- a/pvlib/tests/test_transformer.py +++ b/pvlib/tests/test_transformer.py @@ -5,7 +5,7 @@ from pvlib import transformer -def test_simple_transformer(): +def test_simple_efficiency(): # define test inputs input_power = pd.Series([ From 32b1aa097c60fa0d33fc65bc81528f6aa8146077 Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Tue, 21 May 2024 16:01:54 -0700 Subject: [PATCH 41/53] Update pvlib/transformer.py Co-authored-by: Echedey Luis <80125792+echedey-ls@users.noreply.github.com> --- pvlib/transformer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index 37c4092527..fdc81d222f 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -52,11 +52,11 @@ def simple_efficiency( Total loss is the variable load loss, plus a constant no-load loss: - .. math:: + .. math:: - L_{total}(P_{out}) = L_{no, load} + L_{load}(P_{out}) + L_{total}(P_{out}) &= L_{no, load} + L_{load}(P_{out}) - L_{total}(P_{out}) = L_{no, load} + L_{full, load} \times P^2_{out} + L_{total}(P_{out}) &= L_{no, load} + L_{full, load} \times P^2_{out} Conservation of energy: From 477699da32ab3fffe2c20e127408406bd8bc7005 Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Wed, 22 May 2024 12:17:55 -0700 Subject: [PATCH 42/53] Update pvlib/transformer.py Co-authored-by: Kevin Anderson --- pvlib/transformer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index fdc81d222f..4018e1c48a 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -46,7 +46,7 @@ def simple_efficiency( .. math:: - L_{load}(P_{out}) &= L_{load}(P_{out}) \times P^2_{out} + L_{load}(P_{out}) &= L_{load}(P_{rated}) \times P^2_{out} L_{load}(P_{out}) &= L_{full, load} \times P^2_{out} From d488cda2d3899bec5fc991164c72e1f1a99817e2 Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Wed, 22 May 2024 12:18:05 -0700 Subject: [PATCH 43/53] Update pvlib/transformer.py Co-authored-by: Kevin Anderson --- pvlib/transformer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index 4018e1c48a..eee3ad40af 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -86,7 +86,7 @@ def simple_efficiency( P_{out} = \frac{-1 \pm \sqrt{1 - 4 L_{full, load} - \times L_{no, load} - P_{in}}}{2 L_{no, load} - P_{in}} + \times L_{no, load} - P_{in}}}{2 L_{full, load}} Note that the positive root must be the correct one if the output power is positive. From 8ed3c6570f992820b5acba80498d9d2a84fd0e4f Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Tue, 28 May 2024 14:59:41 -0700 Subject: [PATCH 44/53] Update docs/sphinx/source/whatsnew/v0.11.0.rst Co-authored-by: Adam R. Jensen <39184289+AdamRJensen@users.noreply.github.com> --- docs/sphinx/source/whatsnew/v0.11.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sphinx/source/whatsnew/v0.11.0.rst b/docs/sphinx/source/whatsnew/v0.11.0.rst index a4cbc3179c..798c91ca9f 100644 --- a/docs/sphinx/source/whatsnew/v0.11.0.rst +++ b/docs/sphinx/source/whatsnew/v0.11.0.rst @@ -15,7 +15,7 @@ Deprecations Enhancements ~~~~~~~~~~~~ -* Add a simple transformer efficiency model :py:func:`pvlib.transformer.simple_efficiency` +* Add a simple transformer efficiency model :py:func:`pvlib.transformer.simple_efficiency`. (:issue:`1269`, :pull:`2053`) From 482e3b41358792c5aeb1425733ae4e74a8418e9f Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Mon, 17 Jun 2024 07:29:35 -0600 Subject: [PATCH 45/53] Update pvlib/transformer.py Co-authored-by: Echedey Luis <80125792+echedey-ls@users.noreply.github.com> --- pvlib/transformer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index eee3ad40af..c7db86de46 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -72,7 +72,7 @@ def simple_efficiency( .. math:: - P_{out} &= \frac{-b +- \sqrt{b^2 - 4ac}}{2a} + P_{out} &= \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} a &= L_{full, load} From 59657b82ace684ff4fd84c565f684fa0224e2acd Mon Sep 17 00:00:00 2001 From: Kurt Rhee <33131958+kurt-rhee@users.noreply.github.com> Date: Mon, 17 Jun 2024 07:29:57 -0600 Subject: [PATCH 46/53] Update pvlib/transformer.py Co-authored-by: Echedey Luis <80125792+echedey-ls@users.noreply.github.com> --- pvlib/transformer.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index c7db86de46..5c952dcc1c 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -16,6 +16,13 @@ def simple_efficiency( The equation used in this function can be derived from [1]_. + For a zero input power, the output power will be negative. + This means the transformer will consume energy from the grid at night if + it stays connected (due to the parallel impedance in the equivalent + circuit). + If the input power is negative, the output power will be even more + negative; so the model can be used bidirectionally when drawing + energy from the grid. Parameters ---------- From c8ebe38c375626a9ed18d0b4b058e7298f1ea410 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Tue, 18 Jun 2024 19:35:03 -0400 Subject: [PATCH 47/53] clean up derivation and docstring --- pvlib/transformer.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index 5c952dcc1c..95aa0ec554 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -11,7 +11,7 @@ def simple_efficiency( input_power, no_load_loss, load_loss, transformer_rating ): r''' - Calculate the energy at the output terminal of the transformer + Calculate the power at the output terminal of the transformer after taking into account efficiency using a simple calculation. The equation used in this function can be derived from [1]_. @@ -27,7 +27,7 @@ def simple_efficiency( Parameters ---------- input_power : numeric - The real power input to the transformer. [W] + The real AC power input to the transformer. [W] no_load_loss : numeric The constant losses experienced by a transformer, even @@ -44,18 +44,18 @@ def simple_efficiency( Returns ------- output_power : numeric - Real power output. [W] + Real AC power output. [W] Notes ------- - First, assume that the load loss is proportional to the square of output - power. + First, assume that the load loss (as a fraction of rated power $P_{nom}$) + is proportional to the square of output power: .. math:: - L_{load}(P_{out}) &= L_{load}(P_{rated}) \times P^2_{out} + L_{load}(P_{out}) &= L_{load}(P_{rated}) \times (P_{out} / P_{nom})^2 - L_{load}(P_{out}) &= L_{full, load} \times P^2_{out} + L_{load}(P_{out}) &= L_{full, load} \times \times (P_{out} / P_{nom})^2 Total loss is the variable load loss, plus a constant no-load loss: @@ -63,37 +63,38 @@ def simple_efficiency( L_{total}(P_{out}) &= L_{no, load} + L_{load}(P_{out}) - L_{total}(P_{out}) &= L_{no, load} + L_{full, load} \times P^2_{out} + L_{total}(P_{out}) &= L_{no, load} + L_{full, load} \times (P_{out} / P_{nom})^2 - Conservation of energy: + By conservation of energy, total loss is the difference between input and + output power: .. math:: - P_{in} &= P_{out} + L_{total}(P_{out}) + \frac{P_{in}}{P_{nom}} &= \frac{P_{out}}{P_{nom}} + L_{total}(P_{out}) - P_{in} &= P_{out} + L_{no, load} + L_{full, load} \times P^2_{out} + \frac{P_{in}}{P_{nom}} &= \frac{P_{out}}{P_{nom}} + L_{no, load} + L_{full, load} \times (P_{out} / P_{nom})^2 Now use quadratic formula to solve for :math:`P_{out}` as a function of :math:`P_{in}`. .. math:: - P_{out} &= \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} + \frac{P_{out}}{P_{nom}} &= \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} a &= L_{full, load} b &= 1 - c &= L_{no, load} - P_{in} + c &= L_{no, load} - P_{in} / P_{nom} Therefore: .. math:: - P_{out} = \frac{-1 \pm \sqrt{1 - 4 L_{full, load} + P_{out} = P_{nom} \frac{-1 \pm \sqrt{1 - 4 L_{full, load} - \times L_{no, load} - P_{in}}}{2 L_{full, load}} + \times (L_{no, load} - P_{in}/P_{nom})}}{2 L_{full, load}} Note that the positive root must be the correct one if the output power is positive. From 9164c671d06bcc4ad7193d193ac3d773d511b0ae Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Tue, 18 Jun 2024 19:35:20 -0400 Subject: [PATCH 48/53] change code calculations to match docstring --- pvlib/transformer.py | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index 95aa0ec554..d107a9d6f2 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -105,30 +105,15 @@ def simple_efficiency( .. [1] Central Station Engineers of the Westinghouse Electric Corporation, "Electrical Transmission and Distribution Reference Book" 4th Edition. pg. 101. - ''' - # calculate the load loss in terms of VA instead of percent - loss_at_full_load = ( - (no_load_loss + load_loss) * transformer_rating - ) - no_load_loss = no_load_loss * transformer_rating - load_loss = loss_at_full_load - no_load_loss - - # calculate how much power is lost - combined_loss = ( - (1 / (2 * load_loss)) * - ( - (transformer_rating ** 2) + - (2 * load_loss * input_power) - - (transformer_rating * np.sqrt( - (transformer_rating ** 2) + - (4 * load_loss) * (input_power - no_load_loss) - )) - ) - ) - - # calculate final output power given calculated losses - output_power = input_power - combined_loss + input_power_normalized = input_power / transformer_rating + + a = load_loss + b = 1 + c = no_load_loss - input_power_normalized + + output_power_normalized = (-b + (b**2 - 4*a*c)**0.5) / (2 * a) + output_power = output_power_normalized * transformer_rating return output_power From 816fe2aabe963b2244dd542fca21ee0a9fa4c331 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Tue, 18 Jun 2024 19:52:01 -0400 Subject: [PATCH 49/53] test recovery of no-load and full-load values --- pvlib/tests/test_transformer.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pvlib/tests/test_transformer.py b/pvlib/tests/test_transformer.py index 60f884c280..0739a9e95a 100644 --- a/pvlib/tests/test_transformer.py +++ b/pvlib/tests/test_transformer.py @@ -38,3 +38,23 @@ def test_simple_efficiency(): # determine if expected results are obtained assert_allclose(calculated_output_power, expected_output_power) + + +def test_simple_efficiency_known_values(): + no_load_loss = 0.005 + load_loss = 0.01 + rating = 1000 + args = (no_load_loss, load_loss, rating) + + # verify correct behavior at no-load condition + assert_allclose( + transformer.simple_efficiency(no_load_loss*rating, *args), + 0.0 + ) + + # verify correct behavior at rated condition + assert_allclose( + transformer.simple_efficiency(rating*(1 + no_load_loss + load_loss), + *args), + rating, + ) From be62da6411d07b2637e234a2f1b3a8d4bb016092 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Tue, 18 Jun 2024 20:01:11 -0400 Subject: [PATCH 50/53] bit more cleanup --- pvlib/transformer.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index d107a9d6f2..3d1ae06e44 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -4,8 +4,6 @@ Transformer models calculate AC power output and losses at a given input power. """ -import numpy as np - def simple_efficiency( input_power, no_load_loss, load_loss, transformer_rating @@ -48,14 +46,14 @@ def simple_efficiency( Notes ------- - First, assume that the load loss (as a fraction of rated power $P_{nom}$) - is proportional to the square of output power: + First, assume that the load loss (as a fraction of rated power + :math:`P_{nom}`$) is proportional to the square of output power: .. math:: L_{load}(P_{out}) &= L_{load}(P_{rated}) \times (P_{out} / P_{nom})^2 - L_{load}(P_{out}) &= L_{full, load} \times \times (P_{out} / P_{nom})^2 + L_{load}(P_{out}) &= L_{full, load} \times (P_{out} / P_{nom})^2 Total loss is the variable load loss, plus a constant no-load loss: @@ -105,14 +103,14 @@ def simple_efficiency( .. [1] Central Station Engineers of the Westinghouse Electric Corporation, "Electrical Transmission and Distribution Reference Book" 4th Edition. pg. 101. - ''' + ''' # noqa: E501 input_power_normalized = input_power / transformer_rating a = load_loss b = 1 c = no_load_loss - input_power_normalized - + output_power_normalized = (-b + (b**2 - 4*a*c)**0.5) / (2 * a) output_power = output_power_normalized * transformer_rating From 21abcde63261adc55aab3a133eab0e504ccabc9e Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Tue, 18 Jun 2024 20:08:46 -0400 Subject: [PATCH 51/53] typo --- pvlib/transformer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index 3d1ae06e44..ad99e49550 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -47,7 +47,7 @@ def simple_efficiency( Notes ------- First, assume that the load loss (as a fraction of rated power - :math:`P_{nom}`$) is proportional to the square of output power: + :math:`P_{nom}`) is proportional to the square of output power: .. math:: From db18c4218d40aa97793898bf35004f62d48a648c Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Wed, 19 Jun 2024 16:38:04 -0400 Subject: [PATCH 52/53] Apply suggestions from code review Co-authored-by: Cliff Hansen --- pvlib/transformer.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index ad99e49550..469f3ac019 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -46,16 +46,16 @@ def simple_efficiency( Notes ------- - First, assume that the load loss (as a fraction of rated power + First, assume that the load loss :math:`L_{load}` (as a fraction of rated power :math:`P_{nom}`) is proportional to the square of output power: .. math:: L_{load}(P_{out}) &= L_{load}(P_{rated}) \times (P_{out} / P_{nom})^2 - L_{load}(P_{out}) &= L_{full, load} \times (P_{out} / P_{nom})^2 + &= L_{full, load} \times (P_{out} / P_{nom})^2 - Total loss is the variable load loss, plus a constant no-load loss: + Total loss is the constant no-load loss plus the variable load loss: .. math:: @@ -73,7 +73,7 @@ def simple_efficiency( \frac{P_{in}}{P_{nom}} &= \frac{P_{out}}{P_{nom}} + L_{no, load} + L_{full, load} \times (P_{out} / P_{nom})^2 - Now use quadratic formula to solve for :math:`P_{out}` as a function of + Now use the quadratic formula to solve for :math:`P_{out}` as a function of :math:`P_{in}`. .. math:: @@ -94,7 +94,7 @@ def simple_efficiency( \times (L_{no, load} - P_{in}/P_{nom})}}{2 L_{full, load}} - Note that the positive root must be the correct one if the output power is + The positive root should be chosen, so that the output power is positive. From 52a259391864c74635c4c74f21dbeba06b177dc4 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Wed, 19 Jun 2024 16:48:02 -0400 Subject: [PATCH 53/53] Apply suggestions from code review --- pvlib/transformer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pvlib/transformer.py b/pvlib/transformer.py index 469f3ac019..3b66b0beb3 100644 --- a/pvlib/transformer.py +++ b/pvlib/transformer.py @@ -61,7 +61,7 @@ def simple_efficiency( L_{total}(P_{out}) &= L_{no, load} + L_{load}(P_{out}) - L_{total}(P_{out}) &= L_{no, load} + L_{full, load} \times (P_{out} / P_{nom})^2 + &= L_{no, load} + L_{full, load} \times (P_{out} / P_{nom})^2 By conservation of energy, total loss is the difference between input and @@ -71,7 +71,7 @@ def simple_efficiency( \frac{P_{in}}{P_{nom}} &= \frac{P_{out}}{P_{nom}} + L_{total}(P_{out}) - \frac{P_{in}}{P_{nom}} &= \frac{P_{out}}{P_{nom}} + L_{no, load} + L_{full, load} \times (P_{out} / P_{nom})^2 + &= \frac{P_{out}}{P_{nom}} + L_{no, load} + L_{full, load} \times (P_{out} / P_{nom})^2 Now use the quadratic formula to solve for :math:`P_{out}` as a function of :math:`P_{in}`.