You are on page 1of 27

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/337901276

Integration DIgSILENT - Python. An introduction.

Presentation · December 2019


DOI: 10.13140/RG.2.2.10504.98568

CITATIONS READS

0 4,750

2 authors, including:

Francisco Gonzalez-Longatt
fglongatt LTD
494 PUBLICATIONS 4,226 CITATIONS

SEE PROFILE

All content following this page was uploaded by Francisco Sanchez Gorostiza on 11 December 2019.

The user has requested enhancement of the downloaded file.


DIgSILENT PowerFactory
fglongatt.org

Integration

All rights reserved. No part of this publication may be reproduced or distributed in any form without permission of the author. Copyright © 208-2019. http:www.fglongatt.org
DIgSILENT - Python
9th December 2019
Loughborough University
Conversations about DIgSILENT PowerFactory)

United Kingdom
Francisco Sanchez, PhD Researcher
Francisco Sancehz and Prof Francisco M. Gonzalez-Longatt PhD | fglongatt@fglongatt.org | Copyright © 2008-2019 1/25
Conversations about DIgSILENT
PowerFactory
Prof. Francisco Gonzalez-Longatt PhD

DIgSILENT PowerFactory

All rights reserved. No part of this publication may be reproduced or distributed in any form without permission of the author. Copyright © 208-2019. http:www.fglongatt.org
Integration
DIgSILENT - Python
An introduction
Conversations about DIgSILENT PowerFactory)

Copyright Notice
The documents are created by Francisco M. Gonzalez-Longatt and contain copyrighted material, trademarks, and other proprietary information. All rights reserved. No part of the documents may be reproduced or
copied in any form or by any means - such as graphic, electronic, or mechanical, including photocopying, taping, or information storage and retrieval systems without the prior written permission of Francisco M.
Gonzalez-Longatt . The use of these documents by you, or anyone else authorized by you, is prohibited unless specifically permitted by Francisco M. Gonzalez-Longatt. You may not alter or remove any
trademark, copyright or other notice from the documents. The documents are provided “as is” and Francisco M. Gonzalez-Longatt shall not have any responsibility or liability whatsoever for the results of use of the
documents by you.
Francisco Sancehz and Prof Francisco M. Gonzalez-Longatt PhD | fglongatt@fglongatt.org | Copyright © 2008-2019 2/25
Overview
I. Introduction V. Python-DIgSILENT Integration
II. Python installation and setup VI. PowerFactorySim Class (PFSim)
III. Essential Python Libraries
IV. Python Basics

All rights reserved. No part of this publication may be reproduced or distributed in any form without permission of the author. Copyright © 208-2019. http:www.fglongatt.org
Conversations about DIgSILENT PowerFactory)

Francisco Sancehz and Prof Francisco M. Gonzalez-Longatt PhD | fglongatt@fglongatt.org | Copyright © 2008-2019 3/25
I. Introduction
• What is Python?

All rights reserved. No part of this publication may be reproduced or distributed in any form without permission of the author. Copyright © 208-2019. http:www.fglongatt.org
• Applications

And many more …

• Python 2 vs. Python 3? (https://pythonclock.org/)


Conversations about DIgSILENT PowerFactory)

• Need help?
• https://www.python.org/about/gettingstarted/
Francisco Sancehz and Prof Francisco M. Gonzalez-Longatt PhD | fglongatt@fglongatt.org | Copyright © 2008-2019 4/25
II. Python installation and setup
• Installing Python is quick and easy. (You might have it
already!)

• https://docs.anaconda.com/anaconda/install/windows

All rights reserved. No part of this publication may be reproduced or distributed in any form without permission of the author. Copyright © 208-2019. http:www.fglongatt.org
• It is recommend installing it from the Anaconda
distribution:
Conversations about DIgSILENT PowerFactory)

Francisco Sancehz and Prof Francisco M. Gonzalez-Longatt PhD | fglongatt@fglongatt.org | Copyright © 2008-2019 5/25
II. Python installation and setup
• After installation:
• Start the IDE Spyder by typing spyder in the
Anaconda prompt or start menu in Windows.

All rights reserved. No part of this publication may be reproduced or distributed in any form without permission of the author. Copyright © 208-2019. http:www.fglongatt.org
• Similarly, to open Jupyter notebooks.

http://jupyter.org/index.html
Conversations about DIgSILENT PowerFactory)

From: http://jupyter.org/index.html

Francisco Sancehz and Prof Francisco M. Gonzalez-Longatt PhD | fglongatt@fglongatt.org | Copyright © 2008-2019 6/25
II. Python installation and setup
• Python environment management:
– DIgSILENT 2016 supports Python 3.5
– DIgSILENT 2018 supports Python 3.6

All rights reserved. No part of this publication may be reproduced or distributed in any form without permission of the author. Copyright © 208-2019. http:www.fglongatt.org
– DIgSILENT 2019 supports Python 3.7
• Easiest way to handle multiple environments is by
using Anaconda. Simply type:

• To install new modules type the following command:


Conversations about DIgSILENT PowerFactory)

Francisco Sancehz and Prof Francisco M. Gonzalez-Longatt PhD | fglongatt@fglongatt.org | Copyright © 2008-2019 7/25
III. Essential Python libraries
• For research and engineering the libraries most
widely used are:
– NumPy

All rights reserved. No part of this publication may be reproduced or distributed in any form without permission of the author. Copyright © 208-2019. http:www.fglongatt.org
– pandas
– Matplotlib
– Scikit-Learn
Conversations about DIgSILENT PowerFactory)

Open the Jupyter notebook:


“Essential Python libraries”

Francisco Sancehz and Prof Francisco M. Gonzalez-Longatt PhD | fglongatt@fglongatt.org | Copyright © 2008-2019 8/25
IV. Python basics
• For simplicity, we will go over this section using a
Jupyter notebook named: “Python Basics”.

All rights reserved. No part of this publication may be reproduced or distributed in any form without permission of the author. Copyright © 208-2019. http:www.fglongatt.org
Conversations about DIgSILENT PowerFactory)

Francisco Sancehz and Prof Francisco M. Gonzalez-Longatt PhD | fglongatt@fglongatt.org | Copyright © 2008-2019 9/25
V. Python – DIgSILENT integration
• Engine mode vs. Internal mode
– We will focus on Engine mode
• Essential interface code:

All rights reserved. No part of this publication may be reproduced or distributed in any form without permission of the author. Copyright © 208-2019. http:www.fglongatt.org
1. The “powerfactory” module must be imported:
1. import powerfactory
– This module interfaces with the PowerFactory API
(Application Programming Interface) and gives access to
multiple data in PowerFactory such as
• Objects
• All attributes (element data, results)
• All commands (load flow calculation, etc.)
Conversations about DIgSILENT PowerFactory)

• Built-in DPL functions

Francisco Sancehz and Prof Francisco M. Gonzalez-Longatt PhD | fglongatt@fglongatt.org | Copyright © 2008-2019 10/25
V. Python – DIgSILENT integration
2. To gain access to the PowerFactory environment,
the following command must be inputted:

All rights reserved. No part of this publication may be reproduced or distributed in any form without permission of the author. Copyright © 208-2019. http:www.fglongatt.org
2. app = powerfactory.GetApplication()

• Open the Jupyter notebook called:


“Python + DIgSILENT” for some working examples.

• Bear in mind that you must first import the networks


called “2A4G” and “ChaTime_Start”, included with
the course files, to DIgSILENT.
Conversations about DIgSILENT PowerFactory)

Francisco Sancehz and Prof Francisco M. Gonzalez-Longatt PhD | fglongatt@fglongatt.org | Copyright © 2008-2019 11/25
Conversations about DIgSILENT PowerFactory)

Francisco Sancehz and Prof Francisco M. Gonzalez-Longatt PhD | fglongatt@fglongatt.org | Copyright © 2008-2019
V. Python – DIgSILENT integration
• Selection of working examples on Jupyter Notebook:

12/25

All rights reserved. No part of this publication may be reproduced or distributed in any form without permission of the author. Copyright © 208-2019. http:www.fglongatt.org
Conversations about DIgSILENT PowerFactory)

• Network:

• Example 0:

Francisco Sancehz and Prof Francisco M. Gonzalez-Longatt PhD | fglongatt@fglongatt.org | Copyright © 2008-2019
V. Python – DIgSILENT integration

13/25

All rights reserved. No part of this publication may be reproduced or distributed in any form without permission of the author. Copyright © 208-2019. http:www.fglongatt.org
Conversations about DIgSILENT PowerFactory)

• Example 1:

Francisco Sancehz and Prof Francisco M. Gonzalez-Longatt PhD | fglongatt@fglongatt.org | Copyright © 2008-2019
– Static simulations: Load Flow
V. Python – DIgSILENT integration

14/25

All rights reserved. No part of this publication may be reproduced or distributed in any form without permission of the author. Copyright © 208-2019. http:www.fglongatt.org
Conversations about DIgSILENT PowerFactory)

• Example 2:

Francisco Sancehz and Prof Francisco M. Gonzalez-Longatt PhD | fglongatt@fglongatt.org | Copyright © 2008-2019
– Static simulations: Short-Circuit
V. Python – DIgSILENT integration

15/25

All rights reserved. No part of this publication may be reproduced or distributed in any form without permission of the author. Copyright © 208-2019. http:www.fglongatt.org
V. Python – DIgSILENT integration
• Example 3:
– Static simulations: Modal analysis

All rights reserved. No part of this publication may be reproduced or distributed in any form without permission of the author. Copyright © 208-2019. http:www.fglongatt.org
Import and
activate project

Plot the
Backup project
eigenvalues

Select the
Get generators
eigenvalues

Switch to
classical model Read csv file
representation
Conversations about DIgSILENT PowerFactory)

Prepare Export results


calculation object

Francisco Sancehz and Prof Francisco M. Gonzalez-Longatt PhD | fglongatt@fglongatt.org | Copyright © 2008-2019 16/25
V. Python – DIgSILENT integration
• Example 4:
– Quasi-Dynamic simulations
– What is a Quasi-Dynamic simulation?

All rights reserved. No part of this publication may be reproduced or distributed in any form without permission of the author. Copyright © 208-2019. http:www.fglongatt.org
Conversations about DIgSILENT PowerFactory)

Francisco Sancehz and Prof Francisco M. Gonzalez-Longatt PhD | fglongatt@fglongatt.org | Copyright © 2008-2019 17/25
V. Python – DIgSILENT integration
• Network: WSCC Test Case 9-Bus System
Stage A
Define new time

All rights reserved. No part of this publication may be reproduced or distributed in any form without permission of the author. Copyright © 208-2019. http:www.fglongatt.org
characteristic

Assign
characteristic to
Load A

Stage B
Set-up Quasi-
dynamic
simulation
Execute Quasi-
dynamic
simulation
Conversations about DIgSILENT PowerFactory)

Plot results

Francisco Sancehz and Prof Francisco M. Gonzalez-Longatt PhD | fglongatt@fglongatt.org | Copyright © 2008-2019 18/25
V. Python – DIgSILENT integration
• Quasi-Dynamic simulation
– Stage A:
• Define new time characteristic

All rights reserved. No part of this publication may be reproduced or distributed in any form without permission of the author. Copyright © 208-2019. http:www.fglongatt.org
• Assign characteristic to Load A
Conversations about DIgSILENT PowerFactory)

Francisco Sancehz and Prof Francisco M. Gonzalez-Longatt PhD | fglongatt@fglongatt.org | Copyright © 2008-2019 19/25
V. Python – DIgSILENT integration
• Quasi-Dynamic simulation
– Stage B: Exercise: Create a voltage plot
• Set up and execute

All rights reserved. No part of this publication may be reproduced or distributed in any form without permission of the author. Copyright © 208-2019. http:www.fglongatt.org
• Plot results
Conversations about DIgSILENT PowerFactory)

Francisco Sancehz and Prof Francisco M. Gonzalez-Longatt PhD | fglongatt@fglongatt.org | Copyright © 2008-2019 20/25
VI. PowerFactorySim Class
• To exploit the scripting capabilities of Python it is
useful to create a class that includes several
methods to perform different calculations.

All rights reserved. No part of this publication may be reproduced or distributed in any form without permission of the author. Copyright © 208-2019. http:www.fglongatt.org
• The PowerFactorySim class contains methods for:
– Load Flow
– Short Circuit
– Quasi-Dynamic
– Modal analysis
– RMS and EMT dynamics
Conversations about DIgSILENT PowerFactory)

• More details in the book:


Francisco Sancehz and Prof Francisco M. Gonzalez-Longatt PhD | fglongatt@fglongatt.org | Copyright © 2008-2019 21/25
VI. PowerFactorySim Class
• Excerpt from the PowerFactorySim Class:
– Quasi-dynamic simulation methods

All rights reserved. No part of this publication may be reproduced or distributed in any form without permission of the author. Copyright © 208-2019. http:www.fglongatt.org
Preparation

Execution

Results
Conversations about DIgSILENT PowerFactory)

Francisco Sancehz and Prof Francisco M. Gonzalez-Longatt PhD | fglongatt@fglongatt.org | Copyright © 2008-2019 22/25
VI. PowerFactorySim Class
• Open the Jupyter notebook called:
“Python + DIgSILENT + pfsim” for some working
examples.

All rights reserved. No part of this publication may be reproduced or distributed in any form without permission of the author. Copyright © 208-2019. http:www.fglongatt.org
• The network used for these examples is the IEEE
39-bus test system.
Conversations about DIgSILENT PowerFactory)

Francisco Sancehz and Prof Francisco M. Gonzalez-Longatt PhD | fglongatt@fglongatt.org | Copyright © 2008-2019 23/25
VI. PowerFactorySim Class
• Example calculations: Generator’s frequency for SC on Bus 06:
Different clearing times

All rights reserved. No part of this publication may be reproduced or distributed in any form without permission of the author. Copyright © 208-2019. http:www.fglongatt.org
Generators frequency for SC on Bus 06
Conversations about DIgSILENT PowerFactory)

Quasi-Dynamic simulation
Francisco Sancehz and Prof Francisco M. Gonzalez-Longatt PhD | fglongatt@fglongatt.org | Copyright © 2008-2019 24/25
Conversations about DIgSILENT PowerFactory)

Francisco Sancehz and Prof Francisco M. Gonzalez-Longatt PhD | fglongatt@fglongatt.org | Copyright © 2008-2019
Detailed model
VI. PowerFactorySim Class
• Example calculations: Parameter Estimation

Equivalent model

25/25

All rights reserved. No part of this publication may be reproduced or distributed in any form without permission of the author. Copyright © 208-2019. http:www.fglongatt.org
Conversations about DIgSILENT
PowerFactory
Prof. Francisco Gonzalez-Longatt PhD

Questions and Answers

All rights reserved. No part of this publication may be reproduced or distributed in any form without permission of the author. Copyright © 208-2019. http:www.fglongatt.org
Join me on LinkedIn
Conversations about DIgSILENT PowerFactory)

Copyright Notice
The documents are created by Francisco M. Gonzalez-Longatt and contain copyrighted material, trademarks, and other proprietary information. All rights reserved. No part of the documents may be reproduced or
copied in any form or by any means - such as graphic, electronic, or mechanical, including photocopying, taping, or information storage and retrieval systems without the prior written permission of Francisco M.
Gonzalez-Longatt . The use of these documents by you, or anyone else authorized by you, is prohibited unless specifically permitted by Francisco M. Gonzalez-Longatt. You may not alter or remove any
trademark, copyright or other notice from the documents. The documents are provided “as is” and Francisco M. Gonzalez-Longatt shall not have any responsibility or liability whatsoever for the results of use of the
documents by you.
Francisco SancehzView
andpublication stats
Prof Francisco M. Gonzalez-Longatt PhD | fglongatt@fglongatt.org | Copyright © 2008-2019 26/25

You might also like