Skip to content
Snippets Groups Projects

Update file SLEW_Case1_Electromagnetic_Phenomena.ipynb

Merged Marc Moritz requested to merge Test_SS24 into master
1 file
+ 1
1
Compare changes
  • Side-by-side
  • Inline
%% Cell type:markdown id: tags:
<div>
<img src="figures/slew_logo.png" style="float: right;height: 15em;">
</div>
# SLEW Case 1 - Electromagnetic Phenomena of Synchronous Machines
## Theoretical background
### The generator and its windings
<img src="figures/SubtransientTransientSteadyMachine.svg" width="600" align="left">
%% Cell type:markdown id: tags:
The winding resistance (of armature i.e. stator) dissipates energy at rate proportional to the current squared. The DC components (part of total phase currents) decay ($T_a$). Those armature currents induce direct currents in the rotor windings. They decay with respect to time constant determined by the particular rotor circuit in which they flow:
- DC component of the damper winding current decays with the d-axis subtransient short-circuit time constant $T''_d$
- DC component of the field current decays with the field winding time constant, called the d-axis transient short circuit time constant $T'_d$
- Resistance of damper windings is much higher than the resistance of the field winding $T''_d \leq T'_d$
*\[text and figure adopted from J. Machowski, Z. Lubosny, J. Bialek, and J. R. Bumby, Power system dynamics: stability and control\]*
%% Cell type:markdown id: tags:
## Case description
%% Cell type:markdown id: tags:
A round-rotor machine has the following values:
- $X_{fd} = 0.1648$, $X_l = 0.15$, $X_d = 1.8099$, $X_q = 1.76$
- $T'_{d_0} = 8.0669 s$, $T''_{d_0} = 0.03 s$, $T'_{q_0} = 0.9991 s$, $T''_{q_0} = 0.07 s$
- $X''_d = 0.2299$, $X'_q = 0.65$, $X''_q = 0.25$
- $f_n = 60 Hz$
%% Cell type:markdown id: tags:
## Case tasks
%% Cell type:markdown id: tags:
1. Calculate $X'_d$, $R_{fd}$, $X_{Dd}$ and $R_{Dd}$ from the given quantities (you can neglect the leakage inductance).
2. Apply $X'_d$ by adjusting *Ld_t* in VILLASweb and generate the corresponding short-circuit current plot.
3. The open circuit time constant $T'_{do}$ shall be increased to $18s$
a.) Find the corresponding value of $R_{fd}$ that leads to that increase.
b.) Apply the new $T'_{do}$ by adjusting *Td0_t* in VILLASweb, run the simulation and observe the impact of such increase.
4. The open circuit time constant $T''_{do}$ shall be increased to $0.09s$
a.) Find the corresponding value of $R_{Dd}$ that leads to that increase.
b.) Reset $T'_{do}$ to its original value and apply the new $T''_{do}$ instead by adjusting *Td0_s* in VILLASweb, run the simulation and observe the impact of such increase.
%% Cell type:markdown id: tags:
**You can check your calculation solutions and process the results from VILLASweb using the prepared notebook cells below.**
%% Cell type:markdown id: tags:
## Case solutions
%% Cell type:markdown id: tags:
#### Setup your Python for post-processing
%% Cell type:markdown id: tags:
Import relevant Python packages by executing the following cell:
%% Cell type:code id: tags:
``` python
from IPython.display import display
from villas.web.result import Result
from pprint import pprint
import tempfile
import os
from villas.dataprocessing.readtools import *
from villas.dataprocessing.timeseries import *
import matplotlib.pyplot as plt
import scipy.io as sio
outputs = sio.loadmat('outputs/case1_output.mat', simplify_cells=True)
%matplotlib widget
```
%% Cell type:markdown id: tags:
### Subtask 1
%% Cell type:markdown id: tags:
*Calculate $X'_d$, $R_{fd}$, $X_{Dd}$ and $R_{Dd}$ from the given quantities (you can neglect the leakage inductance).*
%% Cell type:markdown id: tags:
To check your results, enter your solution for $X'_d$ rounded to 4 digits behind the comma:
%% Cell type:code id: tags:
``` python
Xd_t=input('Xd_t:')
print('Your result is', 'correct!' if round(float(Xd_t),4)==round(outputs['Xd_t'],4) else 'incorrect. You should double-check your calculations.')
```
%% Cell type:markdown id: tags:
To check your results, enter your solution for $R_{fd}$ rounded to 4 digits behind the comma:
%% Cell type:code id: tags:
``` python
Rfd=input('Rfd:')
print('Your result is', 'correct!' if round(float(Rfd),4)==round(outputs['Rfd'],4) else 'incorrect. You should double-check your calculations.')
```
%% Cell type:markdown id: tags:
To check your results, enter your solution for $X_{Dd}$ rounded to 4 digits behind the comma:
%% Cell type:code id: tags:
``` python
XDd=input('XDd:')
print('Your result is', 'correct!' if round(float(XDd),4)==round(outputs['XDd'],4) else 'incorrect. You should double-check your calculations.')
```
%% Cell type:markdown id: tags:
To check your results, enter your solution for $R_{Dd}$ rounded to 4 digits behind the comma:
%% Cell type:code id: tags:
``` python
RDd=input('RDd:')
print('Your result is', 'correct!' if round(float(RDd),4)==round(outputs['RDd'],4) else 'incorrect. You should double-check your calculations.')
```
%% Cell type:markdown id: tags:
### Subtask 2
%% Cell type:markdown id: tags:
*Apply $X'_d$ by adjusting *Ld_t* in VILLASweb and generate the corresponding short-circuit current plot.*
%% Cell type:markdown id: tags:
Enter VILLASweb under [https://slew.rwth-aachen.de/](https://slew.rwth-aachen.de/).
Enter VILLASweb under [https://villas.k8s.eonerc.rwth-aachen.de](https://villas.k8s.eonerc.rwth-aachen.de).
Adjust the parameter *Ld_t* and run a corresponding simulation. Further instructions on how to handle VILLASweb you can find in the [SLEW Platform Tutorial](./SLEW_Platform_Tutorial.ipynb).
Then, enter your code snippet for result download in the following cell:
%% Cell type:code id: tags:
``` python
# Access result using token
r = Result(1, 'xyz', endpoint='https://slew.rwth-aachen.de')
```
%% Cell type:markdown id: tags:
#### Plot the results
%% Cell type:code id: tags:
``` python
results_file_name='EMT_SynGenDQ7odTrapez_OperationalParams_SMIB_Fault_JsonSyngenParams.csv'
# Get file by name
f = r.get_file_by_name(results_file_name)
# Create temp dir
tmpdir = tempfile.mkdtemp()
results_file_path = os.path.join(tmpdir,results_file_name)
# Load files as bytes
f = f.download(dest=results_file_path)
# Get time series object from csv
ts_res1 = read_timeseries_csv(results_file_path, print_status=False)
# Plot the currents
plt.figure(figsize=(8,12))
name_list = ['i_gen_0', 'i_gen_1', 'i_gen_2']
phases = ['a', 'b', 'c']
for name in name_list:
i = name_list.index(name)
plt.subplot(3,1,1+i)
plt.ylabel("current (kA)")
plt.xlabel("time (s)")
plt.plot(ts_res1[name].time, ts_res1[name].values/1e3, label='SG task 2 (phase '+phases[i]+')', color='C0')
plt.xlim([0, 1])
plt.legend(loc='upper right')
plt.show()
```
%% Cell type:markdown id: tags:
### Subtask 3
%% Cell type:markdown id: tags:
*3. The open circuit time constant $T'_{do}$ shall be increased to $18s$
a.) Find the corresponding value of $R_{fd}$ that leads to that increase.
b.) Apply the new $T'_{do}$ by adjusting *Td0_t* in VILLASweb, run the simulation and observe the impact of such increase.*
%% Cell type:markdown id: tags:
### a.)
%% Cell type:markdown id: tags:
To check your results, enter your solution for $R_{fd}$ rounded to 7 digits behind the comma:
%% Cell type:code id: tags:
``` python
Rfd_T3a=input('Rfd in Subtask 3:')
print('Your result is', 'correct!' if round(float(Rfd_T3a),7)==round(outputs['Rfd_T3a'],7) else 'incorrect. You should double-check your calculations.')
```
%% Cell type:markdown id: tags:
### b.)
%% Cell type:markdown id: tags:
Enter VILLASweb under [https://slew.rwth-aachen.de/](https://slew.rwth-aachen.de/).
Adjust the parameter *Td0_t* and run a corresponding simulation. Further instructions on how to handle VILLASweb you can find in the [SLEW Platform Tutorial](./SLEW_Platform_Tutorial.ipynb).
Then, enter your code snippet for result download in the following cell:
%% Cell type:code id: tags:
``` python
# Access result using token
r = Result(1, 'xyz', endpoint='https://slew.rwth-aachen.de')
```
%% Cell type:markdown id: tags:
#### Plot the results
%% Cell type:code id: tags:
``` python
results_file_name='EMT_SynGenDQ7odTrapez_OperationalParams_SMIB_Fault_JsonSyngenParams.csv'
# Get file by name
f = r.get_file_by_name(results_file_name)
# Create temp dir
tmpdir = tempfile.mkdtemp()
results_file_path = os.path.join(tmpdir,results_file_name)
# Load files as bytes
f = f.download(dest=results_file_path)
# Get time series object from csv
ts_res2 = read_timeseries_csv(results_file_path, print_status=False)
# Plot the currents
plt.figure(figsize=(8,12))
name_list = ['i_gen_0', 'i_gen_1', 'i_gen_2']
phases = ['a', 'b', 'c']
for name in name_list:
i = name_list.index(name)
plt.subplot(3,1,1+i)
plt.ylabel("current (kA)")
plt.xlabel("time (s)")
plt.plot(ts_res1[name].time, ts_res1[name].values/1e3, label='SG task 2 (phase '+phases[i]+')', color='C0')
plt.plot(ts_res2[name].time, ts_res2[name].values/1e3, label='SG task 3 (phase '+phases[i]+')', color='C1', linestyle=':')
plt.xlim([0, 1])
plt.legend(loc='upper right')
plt.show()
```
%% Cell type:markdown id: tags:
### Subtask 4
%% Cell type:markdown id: tags:
*4. The open circuit time constant $T''_{do}$ shall be increased to $0.09s$
a.) Find the corresponding value of $R_{Dd}$ that leads to that increase.
b.) Reset $T'_{do}$ to its original value and apply the new $T''_{do}$ instead by adjusting *Td0_s* in VILLASweb, run the simulation and observe the impact of such increase.*
%% Cell type:markdown id: tags:
### a.)
%% Cell type:markdown id: tags:
To check your results, enter your solution for $R_{Dd}$ rounded to 4 digits behind the comma:
%% Cell type:code id: tags:
``` python
RDd_T4a=input('RDd in Subtask 4:')
print('Your result is', 'correct!' if round(float(RDd_T4a),4)==round(outputs['RDd_T4a'],4) else 'incorrect. You should double-check your calculations.')
```
%% Cell type:markdown id: tags:
### b.)
%% Cell type:markdown id: tags:
Enter VILLASweb under [https://slew.rwth-aachen.de/](https://slew.rwth-aachen.de/).
Adjust the parameter *Td0_s* and run a corresponding simulation. Further instructions on how to handle VILLASweb you can find in the [SLEW Platform Tutorial](./SLEW_Platform_Tutorial.ipynb).
Then, enter your code snippet for result download in the following cell:
%% Cell type:code id: tags:
``` python
# Access result using token
r = Result(1, 'xyz', endpoint='https://slew.rwth-aachen.de')
```
%% Cell type:markdown id: tags:
#### Plot the results
%% Cell type:code id: tags:
``` python
results_file_name='EMT_SynGenDQ7odTrapez_OperationalParams_SMIB_Fault_JsonSyngenParams.csv'
# Get file by name
f = r.get_file_by_name(results_file_name)
# Create temp dir
tmpdir = tempfile.mkdtemp()
results_file_path = os.path.join(tmpdir,results_file_name)
# Load files as bytes
f = f.download(dest=results_file_path)
# Get time series object from csv
ts_res3 = read_timeseries_csv(results_file_path, print_status=False)
# Plot the currents
plt.figure(figsize=(8,12))
name_list = ['i_gen_0', 'i_gen_1', 'i_gen_2']
phases = ['a', 'b', 'c']
for name in name_list:
i = name_list.index(name)
plt.subplot(3,1,1+i)
plt.ylabel("current (kA)")
plt.xlabel("time (s)")
plt.plot(ts_res1[name].time, ts_res1[name].values/1e3, label='SG task 2 (phase '+phases[i]+')', color='C0')
plt.plot(ts_res3[name].time, ts_res3[name].values/1e3, label='SG task 4 (phase '+phases[i]+')', color='C1', linestyle=':')
plt.xlim([0, 1])
plt.legend(loc='upper right')
plt.show()
```
Loading