-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first version of TC1 (and LSS1) implementation
- Loading branch information
Showing
33 changed files
with
3,184 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains 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,150 @@ | ||
# Import FMI++ Python library. | ||
import fmipp | ||
import os | ||
import sys | ||
import matplotlib.pyplot as plt | ||
|
||
|
||
#------------------------------------------------------------------------------ | ||
# P L O T T I N G P A R A M E T E R S | ||
#------------------------------------------------------------------------------ | ||
|
||
|
||
Set1Red='#e41a1c' | ||
Set1Blue='#377eb8' | ||
Set1Green='#4daf4a' | ||
Set1Purple='#984ea3' | ||
Set1Orange='#ff7f00' | ||
Set1Yellow='#ffff33' | ||
Set1Brown='#a65628' | ||
Set1Pink='#f781bf' | ||
Set1Gray='#999999' | ||
|
||
lw=2 | ||
|
||
colorOM=Set1Red | ||
|
||
#------------------------------------------------------------------------------ | ||
# F M U P A R A M E T E R S | ||
#------------------------------------------------------------------------------ | ||
|
||
|
||
work_dir=os.getcwd() | ||
logging_on = False | ||
|
||
|
||
#------------------------------------------------------------------------------ | ||
# the matlab controller | ||
#------------------------------------------------------------------------------ | ||
|
||
model_name_M='RmsConverterController_R2014b_sf' | ||
stop_before_event = False | ||
event_search_precision = 1e-10 | ||
integrator_type = fmipp.eu | ||
|
||
path_to_fmu_M = os.path.join(work_dir, model_name_M + '.fmu') | ||
# Extract FMU and retrieve URI to directory. | ||
uri_to_extracted_fmu_M= fmipp.extractFMU( path_to_fmu_M, work_dir ) | ||
# using the FMI 2.0 specification | ||
fmuM = fmipp.FMUModelExchangeV2(uri_to_extracted_fmu_M, model_name_M, logging_on, stop_before_event, event_search_precision, integrator_type ) | ||
# Instantiate the FMU. | ||
status1 = fmuM.instantiate( "my_RMS_controller" ) # instantiate model | ||
|
||
|
||
assert status1 == fmipp.fmiOK | ||
# Initialize the FMU. | ||
status1 = fmuM.initialize() # initialize model | ||
assert status1 == fmipp.fmiOK | ||
|
||
|
||
|
||
|
||
# Initialize the FMU. | ||
stop_time = 20. | ||
stop_time_defined = True | ||
|
||
# status = fmu.initialize( start_time, stop_time_defined, stop_time ) | ||
# assert status == fmipp.fmiOK | ||
|
||
|
||
# Run a simulation, changing the inputs at every synchronization step. Also, save outputs for plotting. | ||
time = 0. | ||
step_size = 0.05 | ||
|
||
# data containers for results | ||
res_time = [] # time steps | ||
res_Id_ref = [] # rotor angle of G1 relative to reference machine angle | ||
res_Iq_ref = [] | ||
|
||
# inputs | ||
|
||
# set the FRT control | ||
fmuM.setRealValue("K_aRCI",0.0) | ||
fmuM.setRealValue("R_on",0.0) | ||
fmuM.setRealValue("R_p", 10.0) | ||
fmuM.setRealValue("I_lim", 1.1) | ||
fmuM.setRealValue("Vd", 1.0) | ||
fmuM.setRealValue("Vq", 0.0) | ||
fmuM.setRealValue("V_pcc_RMS", 1.0) | ||
fmuM.setRealValue("Qref_pu", 0.0) | ||
fmuM.setRealValue("Vdc_pu", 1.0) | ||
|
||
|
||
|
||
# outputs | ||
|
||
Id_ref = fmuM.getRealValue("Id_ref") | ||
Iq_ref = fmuM.getRealValue("Iq_ref") | ||
|
||
print "Id_ref = ", Id_ref | ||
print "Iq_ref = ", Iq_ref | ||
|
||
t0=True | ||
|
||
while ( time < stop_time ): | ||
# Make co-simulation step. | ||
new_step = True | ||
tP = fmuM.integrate( time + step_size) # integrate model | ||
# status = fmuM.doStep( time, step_size, new_step ) | ||
# assert status == fmipp.fmiOK | ||
|
||
# Advance time. | ||
time += step_size | ||
print('t = %s s' %time) | ||
|
||
if time<1.0: | ||
Vpcc=1.0 | ||
vd=1.0 | ||
#status = fmu.setRealValue( 'EvtParam.VREF-SLOT.vrefin', 0.0) | ||
else: | ||
Vpcc=1.00 | ||
vd=0.1 | ||
#status = fmu.setRealValue( 'EvtParam.VREF-SLOT.vrefin', 0.01) | ||
|
||
#status = fmuM.setRealValue( 'V_pcc_RMS', Vpcc) | ||
status = fmuM.setRealValue( 'Vd', vd) | ||
assert status == fmipp.fmiOK | ||
|
||
# Get simulation results | ||
res_time.append( time ) | ||
res_Id_ref.append(fmuM.getRealValue("Id_ref")) | ||
res_Iq_ref.append(fmuM.getRealValue("Iq_ref")) | ||
|
||
# import ipdb; ipdb.set_trace() | ||
|
||
# Plot the results. | ||
plt.plot( res_time, res_Id_ref, 'b-',linewidth=4 ) | ||
plt.xlabel( 'simulation time in s' ) | ||
plt.ylabel( 'd-axis current reference in pu' ) | ||
plt.xlim( 0., stop_time) | ||
plt.ylim( -1., 1. ) | ||
plt.show() | ||
|
||
|
||
plt.plot( res_time, res_Id_ref, 'r-',linewidth=4) | ||
plt.xlabel( 'simulation time in s' ) | ||
plt.ylabel( 'q-axis reference current in p.u.' ) | ||
plt.xlim( 0., stop_time) | ||
plt.show() | ||
|
||
# Done. |
Binary file not shown.
This file contains 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,71 @@ | ||
# ERIGrid JRA2: Test case TC1 mosaik implementation | ||
|
||
This file contains instructions for installing the required tools and packages as well as for running the co-simulation tests of TC1 and its upscaled version (referred to as LSS1). | ||
A detailed description of test case TC1 can be found in [ERIGrid deliverable D-JRA2.2](https://erigrid.eu/dissemination/). | ||
A detailed description of test case LSS1 can be found in [ERIGrid deliverable D-JRA2.3](https://erigrid.eu/dissemination/). | ||
|
||
|
||
## Prerequisits (Windows) | ||
|
||
- **Python** (tested with Python 2.7 32-bit) with packages [**matplotlib**](https://matplotlib.org/users/installing.html) and [**fmipp**](https://pypi.org/project/fmipp/) installed | ||
- **PowerFactory** (tested with PowerFactory 2017 SP3 x86) and the [**FMI++ PowerFactory FMU Export Utility**](https://sourceforge.net/projects/powerfactory-fmu/) | ||
- **MATLAB/Simulink** (tested with MATLAB R2014b 32-bit) and the [**FMI Kit for Simulink**](https://www.3ds.com/products-services/catia/products/dymola/fmi/) | ||
- add the PowerFactory and MATLAB binary directories to the PATH variable | ||
|
||
|
||
**ATTENTION**: The co-simulation toolchain needs to be completely in either 32-bit or 64-bit. | ||
For TC1 it was decided to use consistently **32-bit** for Windows setups. | ||
Therefore, be sure to install **32-bit versions of all tools** (Python, PowerFactory, MATLAB/Simulink)! | ||
|
||
## Open-loop RMS converter | ||
|
||
1. Install all prerequisites as described above. | ||
|
||
2. In the command line, switch to subfolder *Open-loop-RMS* and run script *openLoop.py*: | ||
``` | ||
python openLoop.py | ||
``` | ||
|
||
3. At t=1 a voltage dip should occur, causing the current setpoints to change. | ||
|
||
|
||
## Monolithic PowerFactory Model (TC1) | ||
|
||
1. Install all prerequisites as described above. | ||
|
||
2. Import *monolithic.pfd* to PowerFactory and run it. | ||
|
||
3. The simulation should run accordingly and produce time-domain simulation plots. | ||
|
||
|
||
## Small-scale Co-simulation (TC1) | ||
|
||
1. Install all prerequisites as described above. | ||
|
||
2. In the command line, switch to subfolder *Small Scale Co-simulation* and run script *runme.py*: | ||
``` | ||
python runme.py | ||
``` | ||
|
||
3. between t=1.0 and t=1.18 a voltage dip is emulated at the point of common coupling of the converter. | ||
|
||
|
||
## Upscaled Co-simulation (LSS1) | ||
|
||
This folder contains the co-simulation experiment of upscaled TC1 (also referred to as LSS1). | ||
The 32 individual wind turbines are all FMUs based on the Simulink RMS model. | ||
It showcases the upscaled co-simulation. | ||
|
||
1. Install all prerequisites as described above. | ||
|
||
2. File *codegen.py* is the Python script that generates the Python code for running the co-simulation. (The resulting simulation script is around 6500 lines long, hence it would be tedious to write it without automation). In the command line, switch to subfolder *Small Scale Co-simulation* and run script *codegen.py* to generate *upscaled.py*: | ||
``` | ||
python codegen.py | ||
``` | ||
|
||
3. Finally, run *upscaled.py* from the command line: | ||
``` | ||
python upscaled.py | ||
``` | ||
|
||
4. Plots will be saved in a subfolder as listed in *codegen.py* (there should be 162 plots in total). |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.