Apache Groovy is an object-oriented programming language for the Java platform. This language is widely used in PowSyBl to implement domain specific languages such as the contingency DSL, the action DSL or the DSLs for time-domain simulations. With Groovy, you have access to all features of the framework without any payload.
- to load and save a case file
- to easily run power flow simulations.
It’s possible to extend this DSL with user-friendly functions by writing extensions.
powsyblsh is a script for Linux, provided with a iTools distribution that run the interactive command line Groovy Shell. At start-up, it loads the classes of jars found in the
share/java folder of the iTools distribution. You should consider this option during implementation phase. Once your script is ready for production, run it with the iTools run-script command.
This small example shows how to load a case file and run a power simulation in Groovy:
import com.powsybl.loadflow.LoadFlow // Load a case file network = loadNetwork("eurostag-tutorial-example1.xml") // Run a power flow with OpenLF implementation result = LoadFlow.find("OpenLoadFlow").run(network) println "Computation OK? " + result.isOk() println "Metrics: " + result.getMetrics() // Save the network saveNetwork("XIIDM", network, null, "eurostag-tutorial-example1-after-lf.xml")