"Open Source Implementations of Electromagnetic Transient Algorithms "

 

Hanneli C. A. Tavante - UNIFEI

Prof. Benedito D. Bonatto - UNIFEI

Prof. Maurilio P. Coutinho - UNIFEI

INDUSCON 2018 - November 12th - 14th - São Paulo

DISCLAIMER

More about programming than electromagnetic transients

INDUSCON 2018 - November 12th - 14th - São Paulo

"Open Source Implementations of Electromagnetic Transient Algorithms "

Agenda

  • 1 min theory: Electromagnetic transients
  • Developing good software
  • THTA
  • PyTHTA
  • Future works

INDUSCON 2018 - November 12th - 14th - São Paulo

"Open Source Implementations of Electromagnetic Transient Algorithms "

Electromagnetic Transients

INDUSCON 2018 - November 12th - 14th - São Paulo

H. Dommel

"Open Source Implementations of Electromagnetic Transient Algorithms "

Matrix equations to represent electromagnetic transients

Electromagnetic Transients

INDUSCON 2018 - November 12th - 14th - São Paulo

H. Dommel

"Open Source Implementations of Electromagnetic Transient Algorithms "

ATP

EMTP

Well-known programs:

Closed source; written in Fortran, C++

Let's talk about software

INDUSCON 2018 - November 12th - 14th - São Paulo

"Open Source Implementations of Electromagnetic Transient Algorithms "

good

Good software

  • Easy to maintain
  • Easy to add features
  • Easy to fix bugs
  • Stable environment
  • Easy to set up

INDUSCON 2018 - November 12th - 14th - São Paulo

"Open Source Implementations of Electromagnetic Transient Algorithms "

  • => Programming language
  • => Access to the code

 THTA

Dommel's algorithm + Matlab/Octave + Open Source => High chances to become a good software!

INDUSCON 2018 - November 12th - 14th - São Paulo

"Open Source Implementations of Electromagnetic Transient Algorithms "

Python

  • Very popular in science and engineering
  • Easy to use and prototype
  • Lots of libraries
  • Open Source

INDUSCON 2018 - November 12th - 14th - São Paulo

"Open Source Implementations of Electromagnetic Transient Algorithms "

  • => Programming language  easy to maintain
  • => Access to the code

Open source software has a good chance to become good software

INDUSCON 2018 - November 12th - 14th - São Paulo

"Open Source Implementations of Electromagnetic Transient Algorithms "

PyTHTA

Python + THTA + Open Source => High chances to become a good software!

Work in progress

INDUSCON 2018 - November 12th - 14th - São Paulo

"Open Source Implementations of Electromagnetic Transient Algorithms "

PyTHTA Stages

  1. Replicate the basic THTA features
  2. Organise the code
  3. Plot charts
  4. Replicate advanced THTA features
  5. Create a full library

INDUSCON 2018 - November 12th - 14th - São Paulo

"Open Source Implementations of Electromagnetic Transient Algorithms "

PyTHTA Stages

  1. Replicate the basic THTA features
  2. Organise the code (Under development)
  3. Plot charts
  4. Replicate advanced THTA features
  5. Create a full library

INDUSCON 2018 - November 12th - 14th - São Paulo

"Open Source Implementations of Electromagnetic Transient Algorithms "

PyTHTA Stages

  1. Replicate the basic THTA features

The libraries

 

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

INDUSCON 2018 - November 12th - 14th - São Paulo

"Open Source Implementations of Electromagnetic Transient Algorithms "

PyTHTA Stages

  1. Replicate the basic THTA features

Importing the file

self.df = pd.read_csv('test.csv', header=None)

For this initial step, we shall use the .csv format

INDUSCON 2018 - November 12th - 14th - São Paulo

"Open Source Implementations of Electromagnetic Transient Algorithms "

PyTHTA Stages

  1. Replicate the basic THTA features

Calculate the condutance and map elements

for index, row in self.elements.iterrows():
      if row[0] == 'R':
        resistor = Resistor(row[3])
        self.gkm[index-1] = 1/resistor.value
        self.nh = self.nh + 1
      elif row[0] == 'C':
        capacitor = Capacitor((row[3]*1e-6))
        self.gkm[index-1] = 2*capacitor.value/self.dt
        self.nh = self.nh + 1
      elif row[0] == 'L':
        inductor = Inductor((row[3]*1e-3))
        self.gkm[index-1] = self.dt/(2*inductor.value)
      elif row[0] == 'EDC':
        self.ndcvs = self.ndcvs + 1

INDUSCON 2018 - November 12th - 14th - São Paulo

"Open Source Implementations of Electromagnetic Transient Algorithms "

PyTHTA Stages

  1. Replicate the basic THTA features

Build the G matrix

self.g_matrix = np.zeros((self.elements.shape[0], self.elements.shape[0]))
    for index, row in self.elements.iterrows():
      k = row[1]
      m = row[2]
      if m == 0:
        self.g_matrix[k,k] = self.g_matrix[k,k] + self.gkm[index-1]
      elif k == 0:
        self.g_matrix[m,m] = self.g_matrix[m,m] + self.gkm[index-1]
      else:
        self.g_matrix[k,k] = self.g_matrix[k,k] + self.gkm[index-1]
        self.g_matrix[m,m] = self.g_matrix[m,m] + self.gkm[index-1]
        self.g_matrix[k,m] = self.g_matrix[k,m] + self.gkm[index-1]
        self.g_matrix[m,k] = self.g_matrix[m,k] + self.gkm[index-1]

INDUSCON 2018 - November 12th - 14th - São Paulo

"Open Source Implementations of Electromagnetic Transient Algorithms "

PyTHTA Stages

  1. Replicate the basic THTA features

Build the GAA and GAB matrices

d = self.nodes_qty - self.sources_qty
self.gaa = self.g_matrix[0:d, 0:d]
self.gab = self.g_matrix[0:d, d:self.nodes_qty]
self.gba = self.g_matrix[d:self.nodes_qty, 0:d]
self.gbb = self.g_matrix[d:self.nodes_qty, d:self.nodes_qty]

INDUSCON 2018 - November 12th - 14th - São Paulo

"Open Source Implementations of Electromagnetic Transient Algorithms "

PyTHTA Stages

  1. Replicate the basic THTA features

Simulation (see resolver.py)

INDUSCON 2018 - November 12th - 14th - São Paulo

"Open Source Implementations of Electromagnetic Transient Algorithms "

Example

CSV

T,2,1,100E-6,50E-6,0,0,0,0,0
EDC,2,0,10,0,0,0,0,0,0
R,2,1,4,0,0,0,0,0,2
C,1,0,7,0,0,0,0,0,2
R,1,0,6,0,0,0,0,0,2
NV,1,2,0,0,0,0,0,0,0

INDUSCON 2018 - November 12th - 14th - São Paulo

"Open Source Implementations of Electromagnetic Transient Algorithms "

Image created on CircuitLab

G matrix

INDUSCON 2018 - November 12th - 14th - São Paulo

"Open Source Implementations of Electromagnetic Transient Algorithms "

IA, IB, I

INDUSCON 2018 - November 12th - 14th - São Paulo

"Open Source Implementations of Electromagnetic Transient Algorithms "

VA, VB, V

INDUSCON 2018 - November 12th - 14th - São Paulo

"Open Source Implementations of Electromagnetic Transient Algorithms "

What is not (yet) included in this version

  1. Switches, non linear elements, current sources
  2. Charts
  3. Edge cases
  4. Automated Tests

INDUSCON 2018 - November 12th - 14th - São Paulo

"Open Source Implementations of Electromagnetic Transient Algorithms "

PyTHTA Stages

  1. Replicate the basic THTA features
  2. Organise the code (Under development)

Classes and object oriented programming (work in progress)

INDUSCON 2018 - November 12th - 14th - São Paulo

"Open Source Implementations of Electromagnetic Transient Algorithms "

Future work

Different languages and paradigms

3-Phase simulations

INDUSCON 2018 - November 12th - 14th - São Paulo

"Open Source Implementations of Electromagnetic Transient Algorithms "

INDUSCON 2018 - November 12th - 14th - São Paulo

"Open Source Implementations of Electromagnetic Transient Algorithms "

Thanks!

The authors acknowledge the support from CNPq, INERGE, CAPES, FAPEMIG and UNIFEI. 

Questions?

hannelita@gmail.com

INDUSCON 2018 - November 12th - 14th - São Paulo

"Open Source Implementations of Electromagnetic Transient Algorithms "

Induscon - PyTHTA

By Hanneli Tavante (hannelita)

Induscon - PyTHTA

  • 238
Loading comments...

More from Hanneli Tavante (hannelita)