-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add a simple transformer effficiency model to pvlib #2053
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
43234fc
wrote a simple transformer efficiency model
kurt-rhee f18ef77
edited documentation to include latex, unsure if it will compile corr…
kurt-rhee aafebe8
removed "if __main__"
kurt-rhee ee4210e
removed "if __main__"
kurt-rhee f688078
changed whatsnew rst
kurt-rhee 907efd3
updated to be in compliance with Flake8
kurt-rhee a80bd7f
Update pvlib/transformer.py
kurt-rhee 1072053
Update pvlib/transformer.py
kurt-rhee d8381fe
Update pvlib/transformer.py
kurt-rhee 349604f
+ added transformer to index.rst
kurt-rhee af63760
Update docs/sphinx/source/reference/transformer.rst
kurt-rhee 3bb1364
Update pvlib/transformer.py
kurt-rhee 1571fdd
updated names of loss values and changed to [unitless]
kurt-rhee 77efdde
Update pvlib/transformer.py
kurt-rhee b029b9e
Update pvlib/transformer.py
kurt-rhee 06efabe
Update pvlib/transformer.py
kurt-rhee 9361419
Update pvlib/transformer.py
kurt-rhee aeeb23b
Update pvlib/transformer.py
kurt-rhee 3e0751c
Update pvlib/transformer.py
kurt-rhee 0b18c43
Update pvlib/transformer.py
kurt-rhee 8ab1001
Update pvlib/transformer.py
kurt-rhee aa31498
forgot to update arguments in test function
kurt-rhee 865bfdf
updated formatting of docstring
kurt-rhee eb70aeb
Update pvlib/transformer.py
kurt-rhee 35f122f
Update pvlib/transformer.py
kurt-rhee 5592bc2
Update pvlib/transformer.py
kurt-rhee 63649c8
Update pvlib/transformer.py
kurt-rhee d49fee5
Update pvlib/transformer.py
kurt-rhee 7539402
adding space between equations in docstring
kurt-rhee d5a862c
fixing flake8 linting
kurt-rhee 9fe05f8
removing whitespace
kurt-rhee 99ab409
Update docs/sphinx/source/reference/transformer.rst
kurt-rhee feb2c30
Update pvlib/transformer.py
kurt-rhee e1522be
Update pvlib/transformer.py
kurt-rhee ae378c9
Update pvlib/transformer.py
kurt-rhee 84ddbf2
Update pvlib/transformer.py
kurt-rhee 9a7dbc6
Update pvlib/transformer.py
kurt-rhee 288161b
Update docs/sphinx/source/whatsnew/v0.11.0.rst
kurt-rhee d080cc0
Update pvlib/transformer.py
kurt-rhee 53934ec
Update pvlib/tests/test_transformer.py
kurt-rhee 32b1aa0
Update pvlib/transformer.py
kurt-rhee 477699d
Update pvlib/transformer.py
kurt-rhee d488cda
Update pvlib/transformer.py
kurt-rhee 0318bfa
Merge branch 'main' into main
kurt-rhee 8ed3c65
Update docs/sphinx/source/whatsnew/v0.11.0.rst
kurt-rhee 90d3a61
Merge branch 'main' into main
cwhanse 482e3b4
Update pvlib/transformer.py
kurt-rhee 59657b8
Update pvlib/transformer.py
kurt-rhee c8ebe38
clean up derivation and docstring
kandersolar 9164c67
change code calculations to match docstring
kandersolar 816fe2a
test recovery of no-load and full-load values
kandersolar be62da6
bit more cleanup
kandersolar 21abcde
typo
kandersolar db18c42
Apply suggestions from code review
kandersolar 52a2593
Apply suggestions from code review
kandersolar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import pandas as pd | ||
|
||
from numpy.testing import assert_allclose | ||
|
||
from pvlib import transformer | ||
|
||
|
||
def test_simple_transformer(): | ||
kurt-rhee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
""" | ||
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. | ||
kurt-rhee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
|
||
import numpy as np | ||
|
||
|
||
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. | ||
kurt-rhee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
The equation used in this function can be derived from the reference. | ||
kurt-rhee marked this conversation as resolved.
Show resolved
Hide resolved
kurt-rhee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
kurt-rhee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
First, assume that the load loss is proportional to the square of output | ||
kurt-rhee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
power. | ||
|
||
.. math:: | ||
L_{load}(P_{out}) = L_{load}(P_{out}) * P^2_{out} | ||
kurt-rhee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
L_{load}(P_{out}) = L_{full, load} * P^2_{out} | ||
|
||
Total loss is the variable load loss, plus a constant no-load loss: | ||
kandersolar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
.. 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} | ||
kurt-rhee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
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} | ||
kurt-rhee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Now use quadratic formula to solve for $P_{out}$ as a function of $P_in$. | ||
kurt-rhee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
..math:: | ||
kurt-rhee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
P_{out} = \frac{-b +- \sqrt{b^2 - 4ac}}{2a} | ||
a = L_{full, load} | ||
b = 1 | ||
c = L_{no, load} - P_{in} | ||
kurt-rhee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Therefore: | ||
|
||
..math:: | ||
kurt-rhee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
P_{out} = \frac{-1 +- \sqrt{1 - 4*L_{full, load}*L_{no, load} - | ||
P_{in}}}{2*L_{no, load} - P_{in}} | ||
kurt-rhee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Note that the positive root must be the correct one if the output power in | ||
kurt-rhee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
positive. | ||
|
||
|
||
Parameters | ||
---------- | ||
input_power : numeric | ||
The power that is input into the transformer. [W] | ||
kurt-rhee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
no_load_loss_fraction : numeric | ||
The constant losses experienced by a transformer, even | ||
when the transformer is not under load. [% from 0 to 1] | ||
kurt-rhee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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 | ||
AC power output. [W] | ||
kurt-rhee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
References | ||
---------- | ||
.. [1] Central Station Engineers of the Westinghouse Electric Corporation, | ||
"Electrical Transmission and Distribution Reference Book" 4th Edition. | ||
pg. 101. | ||
kurt-rhee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
''' | ||
|
||
# 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 = ( | ||
kandersolar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
(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 | ||
|
||
return output_power |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.