Skip to content
This repository has been archived by the owner on Jul 17, 2020. It is now read-only.

Update Docs #69

Merged
merged 2 commits into from
Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/src/Examples/example_OMIB.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ This will correctly initialize the system. It essentially will run a power flow
#Will print the initial states. It also give the symbols used to describe those states.
print_device_states(sim)
#Will export a dictionary with the initial condition values to explore
x0_init = get_dict_init_states(sim)
x0_init = get_initial_conditions(sim)
```

## Step 4: Run the Simulation
Expand All @@ -89,7 +89,7 @@ In some cases, the dynamic time step used for the simulation may fail. In such c

After running the simulation, our simulation structure `sim` will have the solution. For that `sim.solution` can be used to explore the solution structure. In this case `sim.solution.t` returns the vector of time, while `sim.solution.u` return the array of states. In addition, `LITS` have two functions to obtain different states of the solution:

- `get_state_series(sim, ("generator-102-1", :δ))`: can be used to obtain the solution as a tuple of time and the required state. In this case, we are obtaining the rotor angle `:δ` of the generator named `"OMIB_Gen"`.
- `get_state_series(sim, ("generator-102-1", :δ))`: can be used to obtain the solution as a tuple of time and the required state. In this case, we are obtaining the rotor angle `:δ` of the generator named `"generator-102-1"`.
- `get_voltagemag_series(sim, 102)`: can be used to obtain the voltage magnitude as a tuple of time and voltage. In this case, we are obtaining the voltage magnitude at bus 102 (where the generator is located).

```julia
Expand Down
3 changes: 1 addition & 2 deletions docs/src/Examples/example_data.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ We will create specific functions to create the components of the inverter as fo

```julia
#Define converter as an AverageConverter
converter_high_power() = AverageConverter(v_rated = 138.0, s_rated = 100.0)
converter_high_power() = AverageConverter(rated_voltage = 138.0, rated_current = 100.0)

#Define Outer Control as a composition of Virtual Inertia + Reactive Power Droop
function outer_control()
Expand Down Expand Up @@ -265,7 +265,6 @@ function inv_case78(static_device)
return PSY.DynamicInverter(
static_device,
1.0, # ω_ref,
100.0, #MVABase
converter_high_power(), #converter
outer_control(), #outer control
inner_control(), #inner control voltage source
Expand Down
129 changes: 114 additions & 15 deletions docs/src/Examples/example_lines.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This tutorial will introduce an example of considering dynamic lines in `LITS`.
Note that this tutorial is for `LITS 0.4.0`.

This tutorial presents a simulation of a three-bus system, with an infinite bus (represented as a voltage source behind an impedance) at bus 1, a one d- one q- machine on bus 2 and an inverter of 19 states, as a virtual synchronous machine at bus 3. The perturbation will be the trip of two of the three circuits (triplicating its resistance and impedance) of the line that connects bus 1 and bus 3. This case also consider a dynamic line model for connection between buses 2 and 3.
This tutorial presents a simulation of a three-bus system, with an infinite bus (represented as a voltage source behind an impedance) at bus 1, a one d- one q- machine on bus 2 and an inverter of 19 states, as a virtual synchronous machine at bus 3. The perturbation will be the trip of two of the three circuits (triplicating its resistance and impedance) of the line that connects bus 1 and bus 3. This case also consider a dynamic line model for connection between buses 2 and 3. We will compare it against a system without dynamic lines.

It is recommended to check `Tutorial 1: OMIB` first, since that includes more details and explanations on all definitions and functions.

Expand All @@ -20,7 +20,7 @@ const PSY = PowerSystems

## Step 2: Data creation

We will load the system already defined in Tutorial 0:
We will load two systems already defined in Tutorial 0:

```julia
threebus_sys = System("threebus_sys.json")
Expand All @@ -31,13 +31,15 @@ In addition, we will create a new copy of the system on which we will simulate t
threebus_sys_dyn = deepcopy(threebus_sys)
```

## Step 3: Build the simulation and initializing the problem
## Step 3: Create the fault and simulation on the Static Lines system

First, we construct the perturbation, by properly computing the new Ybus:
First, we construct the perturbation, by properly computing the new Ybus on the system:

```julia
#Create Ybus_Fault
fault_branches = deepcopy(collect(get_components(Branch, threebus_sys)))
#Make a copy of the original system
sys2 = deepcopy(threebus_sys)
#Triplicates the impedance of the line named "1"
fault_branches = get_components(ACBranch, sys2)
for br in fault_branches
if get_name(br) == "1"
br.r = 3 * br.r
Expand All @@ -46,7 +48,8 @@ for br in fault_branches
br.b = b_new
end
end
Ybus_fault = Ybus(fault_branches, get_components(Bus, threebus_sys))[:, :];
#Obtain the new Ybus
Ybus_fault = Ybus(sys2).data
#Define Fault: Change of YBus
Ybus_change = LITS.ThreePhaseFault(
1.0, #change at t = 1.0
Expand Down Expand Up @@ -74,11 +77,11 @@ We can obtain the initial conditions as:
#Will print the initial states. It also give the symbols used to describe those states.
print_device_states(sim)
#Will export a dictionary with the initial condition values to explore
x0_init = get_dict_init_states(sim)
x0_init = get_initial_conditions(sim)
```


## Step 4: Run the simulation
## Step 4: Run the simulation of the Static Lines System

```julia
#Run the simulation
Expand All @@ -88,20 +91,116 @@ run_simulation!(sim, #simulation structure
)
```

## Step 5: Explore the solution
## Step 5: Store the solution

```julia
using Plots
volt = get_voltagemag_series(sim, 102)
plot(volt, xlabel="time", ylabel="Voltage [pu]", label="V_2")
series2 = get_voltagemag_series(sim, 102)
zoom = [
(series2[1][ix], series2[2][ix])
for (ix, s) in enumerate(series2[1]) if (s > 0.90 && s < 1.6)
];
```


## Step 3.1: Create the fault and simulation on the Dynamic Lines system

An important aspect to consider is that DynamicLines must not be considered in the computation of the Ybus.
First we construct the Dynamic Line, by finding the Line named "3", and then adding it to the system.

```julia
# get component return the Branch on threebus_sys_dyn named "3"
dyn_branch = DynamicBranch(get_component(Branch, threebus_sys_dyn, "3"))
# Adding a dynamic line will inmediately remove the static line from the system.
add_component!(threebus_sys_dyn, dyn_branch)
```

Similarly, we construct the Ybus fault by creating a copy of the original system, but removing the Line "3" to avoid considering it in the Ybus:
```julia
#Make a copy of the original system
sys3 = deepcopy(threebus_sys)
#Remove Line "3"
remove_component!(Line, sys3, "3")
#Triplicates the impedance of the line named "1"
fault_branches2 = get_components(Line, sys3)
for br in fault_branches2
if get_name(br) == "1"
br.r = 3 * br.r
br.x = 3 * br.x
b_new = (from = br.b.from / 3, to = br.b.to / 3)
br.b = b_new
end
end
#Obtain the new Ybus
Ybus_fault_dyn = Ybus(sys3).data
#Define Fault: Change of YBus
Ybus_change_dyn = LITS.ThreePhaseFault(
1.0, #change at t = 1.0
Ybus_fault_dyn, #New YBus
)
```

zoom = [(volt[1][ix], volt[2][ix]) for (ix, s) in enumerate(volt[1]) if (s > 0.90 && s < 1.6)]
plot(zoom, xlabel="time", ylabel="Voltage [pu]", label="V_2")
## Step 4.1: Run the simulation of the Dynamic Lines System

```julia
#Run the simulation
run_simulation!(sim, #simulation structure
IDA(), #Sundials DAE Solver
dtmax = 0.02, #Maximum step size
)
```

Now, we construct the simulation:

```julia
#Time span of our simulation
tspan = (0.0, 30.0)

#Define Simulation
sim_dyn = Simulation(
pwd(), #folder to output results
threebus_sys_dyn, #system
tspan, #time span
Ybus_change_dyn, #Type of perturbation
)
```

We can obtain the initial conditions as:
```julia
#Will print the initial states. It also give the symbols used to describe those states.
print_device_states(sim_dyn)
#Will export a dictionary with the initial condition values to explore
x0_init_dyn = get_initial_conditions(sim_dyn)
```

## Step 5.1: Store the solution

```julia
series2_dyn = get_voltagemag_series(sim_dyn, 102)
zoom_dyn = [
(series2_dyn[1][ix], series2_dyn[2][ix])
for (ix, s) in enumerate(series2_dyn[1]) if (s > 0.90 && s < 1.6)
];
```

## Step 6.1: Compare the solutions:

We can observe the effect of Dynamic Lines

```julia
using Plots
plot(series2_dyn, label="V_gen_dyn")
plot!(series2, label="V_gen_st", xlabel="Time [s]", ylabel = "Voltage [pu]")
```

```@raw html
<img src="../../assets/voltage_lines.png" width="75%"/>
``` ⠀
that looks quite similar. The differences can be observed in the zoom plot:

```julia
plot(zoom_dyn, label="V_gen_dyn")
plot!(zoom, label="V_gen_st", xlabel="Time [s]", ylabel = "Voltage [pu]")
```

```@raw html
<img src="../../assets/voltage_zoom_lines.png" width="75%"/>
Expand Down
Binary file modified docs/src/assets/rotor_angle_OMIB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/src/assets/voltage_OMIB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/src/assets/voltage_lines.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/src/assets/voltage_zoom_lines.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.