upb-lea / openmodelica-microgrid-gym

OpenModelica Microgrid Gym (OMG): An OpenAI Gym Environment for Microgrids
GNU General Public License v3.0
184 stars 38 forks source link

Single Phase System Model #50

Open Webbah opened 4 years ago

Webbah commented 4 years ago

First example: two inverter droop (static?)

Webbah commented 4 years ago

Define states and actions:

states x: f, U, P, Q...?

actions a:

Planned: ODE, which contains f&U-calculations and droop-controller to calculate P&Q depending on f&U (before)

Later:

Webbah commented 4 years ago

component power as state or input?

Webbah commented 4 years ago

First example:

dtheta = f df = sum(Pk)/(J*f)

While in Pk an offset can be considered and in f-ODE droop is inserted: df = (p-droop_linear*(freqs-nomFreq))/(J*freqs)

Result for droop inverter 1 = 0, inverter 2 = 1000 W/Hz and no P-offset (standard solver):

grafik

Webbah commented 4 years ago

Unstable for longer simulations: grafik

grafik

h-bode commented 4 years ago

Q-Droop and voltage implemented:

Observations:

image

image

continues even for longer simulations. ignore the last value which goes to 0, this is just a programming issue.

image

image

The other 2 voltages can be stabilized with the q-droop, but sinve it´s 0 for the load, it reaches 0.

I would have expected it to rise while adjusting (increasing) the load resistance, but this does not seem to have any effect on the resulting voltages?! Increasing it by the factor of 10 or 100 does nothing to it, while decreasing the line impedances results sometimes in numerical issues.

h-bode commented 4 years ago

If anyone has a clue how to get a voltage at v3, which does not decrease that fast, feel free to share ideas :-)

h-bode commented 4 years ago

Relevant parts of the code, basically equation 8 from Olivers paper:

for k in range(num_nodes):
        for j in range(num_nodes):  # l works, due to B is symmetric
            p[k] += voltages[k] * voltages[j] * (-G[k][j]*np.cos(thetas[k] - thetas[j]) + \
                                         B[k][j]*np.sin(thetas[k] - thetas[j]))
            q[k] += voltages[k] * voltages[j] * (-G[k][j]*np.sin(thetas[k] - thetas[j]) + \
                                         B[k][j]*np.cos(thetas[k] - thetas[j]))

Including equation 12 for the return, + an adjusted version for the voltage:

    df = (p-droop_linear*(freqs-nomFreq))/(J*freqs)
    dv = (q - q_droop_linear * (voltages - nomVolt)) / (J * voltages)
    dtheta = freqs * 2 * np.pi