Coder Social home page Coder Social logo

pyvolt's People

Contributors

dinkelbachjan avatar m-mirz avatar martinmoraga avatar simongrimmacs avatar ss391347 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pyvolt's Issues

quickstart example run_nv_powerflow.py

At the end of this quickstart example script, the calculated voltage values are compared with precalculated references.
However, doing an assertion of complex floats is not a good idea and usually fails because of numerical tolerances.
So I'd suggest to do the following:

voltages_ref = [(1-7.970485900477431e-27j), (0.9521818868802214-0.11692768153747995j),
                (0.9642955926931457-0.09862127081290231j), (0.8796973782245792-0.15318580971335868j),
                (0.8758799767843979-0.1554670528853566j), (0.8774339089327876-0.1545390713879984j),
                (0.8704521134131005-0.1574589214738466j), (0.8719578342107204-0.15661905676450852j),
                (0.8731024990161087-0.1561497673751958j), (0.8727417602545003-0.15623359013901236j),
                (0.8740410220986286-0.1565630049874985j), (0.9563016474701451-0.09917826765833906j),
                (0.9592141716734833-0.09896267637101246j), (0.8702137462858025-0.15760036065945185j),
                (0.9239489705253996-0.13105032262255972j)]
epsilon = 1e-4
assert ([val-epsilon for val in voltages] <= voltages_ref <= [val+epsilon for val in voltages]), \
    "Results do not match reference results."

Please let me know if I should push that change.

Error creating Branch of type PowerTransformer

When a branch of type PowerTransformer is created, there is a bug in the function _get_primary_connection. This function shoud not return the PowerTransformerEnd with the higheist nominal voltage but also the PowerTransformerEnd with r>0 and x>0. Independently of the nominal voltage of the PowerTransformerEnd, the parameters x, r can be equal to zero, which results in a singular admittance matrix.

CIM data cannot be reloaded properly

If the underlying CIM data is reloaded ( using function network.System.load_cim_data(...) ), the power flow algorithm fails because the network model is not created properly in this case.

Update and fixate requirements

Describe the bug
Installing the Pyvolt package in an up-to-date environment and executing one of the example scripts leads to an error.
This is caused by changes in Numpy that has removed support for numpy internal datatypes (np.int, np.complex etc.) and replaced them with Python default datatypes.

To avoid this problem in the future Versions should be pinned.
While at it the project could/should be transitioned to the currents standard of PEP621 for project metadata (see e. g. Setuptools explaination

To Reproduce
Steps to reproduce the behavior:

  1. Pull repo and cd into it
  2. (create venv)
  3. pip install .
  4. python examples/quickstart/run_nv_powerflow.py

powerflow algorithm - node type "PV" issue

If a node inside the network typology is an instance of BusType.PV, the powerflow algorithm either produces abstruse results or does not converge at all.

According to file network.py, a node is declared as "PV" type if at least one synchronous machine is connected to it:

pyvolt/pyvolt/network.py

Lines 324 to 331 in e42d566

#TODO the search for PV nodes has not been tested yet
#get a list of Terminals for which the ConductingEquipment is a element of class SynchronousMachine
list_Terminals_SM = [elem for elem in list_Terminals if elem.ConductingEquipment.__class__.__name__ == "SynchronousMachine"]
for terminal in list_Terminals_SM:
node_uuid = terminal.TopologicalNode.mRID
for node in self.nodes:
if node.uuid == node_uuid:
node.type = BusType["PV"]

I am aware of the ToDo remark, so please don't get me wrong...

So, I checked the code in nv_powerflow.py and I am wondering about the following (unfortunately, I don't know the working principle of the algorithm in detail):

def solve(system):
"""It performs powerflow by using rectangular node voltage state variables and considering the current mismatch function.
Solve the non-linear powerflow problem stated by
r = z-h(state) = 0
following the Newton-Raphson approach
delta_state = H^-1 * r
new_state = old_state + delta_state
r: residual function (current mismatch)
z: expected currents
state: rectangular voltages (i.e. [V0_re, V1_re, ..., VN_re, V0_im, V1_im, ... , VN_im])
h: currents calculated from state
H: Jacobian matrix
V: same as state but with complex numbers (i.e. [V0_re+j*V0_im, V1_re+j*V1_im, ...])
"""
nodes_num = system.get_nodes_num()
z = np.zeros(2 * nodes_num)
h = np.zeros(2 * nodes_num)
H = np.zeros((2 * nodes_num, 2 * nodes_num))
for node in system.nodes:
if node.ideal_connected_with =='':
i = node.index
m = 2 * i
i2 = i + nodes_num
node_type = node.type
if node_type == BusType.SLACK:
z[m] = np.real(node.voltage_pu)
z[m + 1] = np.imag(node.voltage_pu)
H[m][i] = 1
H[m + 1][i2] = 1
elif node_type is BusType.PQ:
H[m][:nodes_num] = np.real(system.Ymatrix[i])
H[m][nodes_num:] = - np.imag(system.Ymatrix[i])
H[m+1][:nodes_num] = np.imag(system.Ymatrix[i])
H[m+1][nodes_num:] = np.real(system.Ymatrix[i])
elif node_type is BusType.PV:
z[m + 1] = np.real(node.power)
H[m][:nodes_num] = np.real(system.Ymatrix[i])
H[m][nodes_num:] = - np.imag(system.Ymatrix[i])
epsilon = 10 ** (-10)
#epsilon = 0.01
diff = 5
V = np.ones(nodes_num) + 1j * np.zeros(nodes_num)
num_iter = 0
state = np.concatenate((np.ones(nodes_num), np.zeros(nodes_num)), axis=0)
while diff > epsilon:
for node in system.nodes:
if node.ideal_connected_with =='':
i = node.index
m = 2 * i
i2 = i + nodes_num
node_type = node.type
if node_type is BusType.SLACK:
h[m] = np.inner(H[m], state)
h[m + 1] = np.inner(H[m + 1], state)
elif node_type is BusType.PQ:
z[m] = (np.real(node.power_pu) * np.real(V[i]) +
np.imag(node.power_pu) * np.imag(V[i])) / (np.abs(V[i]) ** 2)
z[m + 1] = (np.real(node.power_pu) * np.imag(V[i]) -
np.imag(node.power_pu) * np.real(V[i])) / (np.abs(V[i]) ** 2)
h[m] = np.inner(H[m], state)
h[m + 1] = np.inner(H[m + 1], state)
elif node_type is BusType.PV:
z[m] = (np.real(node.power_pu) * np.real(V[i]) +
np.imag(node.power_pu) * np.imag(V[i])) / (np.abs(V[i]) ** 2)
h[m] = np.inner(H[m], state)
h[m + 1] = np.abs(V[i])
H[m + 1][i] = np.cos(np.angle(V[i]))
H[m + 1][i2] = np.sin(np.angle(V[i]))

  • According to line 9, variable "z" takes current values.
  • However, in line 48, a power value is actually assigned to "z".
  • Also, why do we assign a real value to z[m + 1] ? Because usually z[m] takes the real values and z[m+1] the imaginary ones if I understand it correctly.
  • That given, is the code in lines 78 and 79 correct?

And by the way, if I set a node containing a synchronous machine to type "PQ" instead of "PV", the algorithm seems to work properly.
But this is most certainly not the way to go, I guess...

Best regards,
Sebastian

State estimation with voltage magnitude, active and reactive power.

Problem description
While using the algorithm of the state estimation our developement team noticed something unusual in the behaviour of the function.
Two behaviours occured with our input:

  • State estimation function went into an infinite loop in this function epsilon value is never converging to the wanted result.
  • When the epsilon value converges the return are some values that are not accurate and descriptive of the grid (like Nan and infinite values)

To Reproduce
Build an example like this one but instead of the Voltage magnitude and phase input provide in input Voltae magnitude(MeasType.V_mag), active and reactive power.

Expected behavior
Return a state of all the input grid with relevant values trough the Result class included in the pyvolt.result module, where all nodes and branches informations after estimation are contained.

Additional context
The issue has already been discussed with Jan Dinkelbach, member of the community, who gave to the team support and noticed that this behaviour is not normal and could be fixed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.