⚡ PowerFactory Scripter
Help you automate PF simulations.
← Other Tools
⏳ Loading DB…
Copied to clipboard!
Code generated!
JSON imported!

Validation Errors

    Warnings

      💡 New here? Browse the Samples & Guides to see worked examples before configuring your script.

      Initialisation

      Input Variables

      Set PowerFactory object parameters before each simulation. Enter the object using its PF path and class (e.g. Gen.ElmSym) and the parameter to modify (e.g. e:qgini).
      GetCalcRelevantObjects() resolves the object query; SetAttribute() writes the value before each run.
      Brute Force: Step Size is the increment (not number of steps); every combination is iterated.
      Optimisation: Bounds define the search space; step is unused.
      Custom: Values come from a scenario Excel file (bounds and step are unused).
      Wildcards (e.g. *.ElmDsl) match multiple objects — the same value is applied to all matched objects.
      # Name ? Object ? Attribute ? Lower
      Bound
      ?
      Upper
      Bound
      ?
      Step
      Size
      ?

      Custom Mode Config

      Excel scenario file with a 3-row header (Variable name / Object / Attribute) + one data row per scenario.
      Row 1 — Variable name: label cell Variable name, then one name per column.
      Row 2 — Object: label cell Object, then PF query per column (e.g. Grid.ElmTerm).
      Row 3 — Attribute: label cell Attribute, then attribute name per column.
      Rows 4+ — Data: first cell = scenario label, then numeric values.
      Wildcard queries (e.g. *.ElmSym) apply the value to all matched objects simultaneously. Sheet name must be Sheet1.

      Contingency Config

      Specify one or more wildcard element queries. The script resolves all matching objects at runtime, then iterates through each contingency (N-1: one element tripped; N-2: two elements tripped simultaneously). A base case (all in service) is always included as the first run.
      Element Query: wildcard PF query (e.g. *.ElmLne, *.ElmSym).
      Filter Attribute: optional attribute to filter resolved objects (e.g. e:Unom, loc_name).
      Filter Value: numeric (e.g. 66), plain string, or wildcard string (e.g. North* — case-insensitive glob).
      N-2 / Combine: when unchecked, pairs are formed within each element type only (line × line, generator × generator). When checked, pairs cross element types too.
      The outserv attribute (1 = out, 0 = in) is always used and restored in a finally block after each run.
      # Element Query ? Filter Attribute ? Op ? Filter Value ?

      Output Variables

      Read results from PowerFactory after each simulation. Scalar reads a single value from any object; Timeseries captures a signal over time (dynamic studies only); Custom lets you write your own Python calculation.
      Scalar uses obj.GetAttribute() on static result variables (e.g. m:u1, c:loading) after solving — check the PF result variable browser for available keys.
      Timeseries requires a Dynamic RMS or EMT study type. Use the PF variable key (e.g. m:u1, m:I:bus1) — same as the result variable browser, not the descriptive label.
      Custom Calculation arguments must be names of other defined Input or Output Variables.
      All variable names must be unique across inputs and outputs.

      Optimisation Settings


      Constraints ?
      Output Variable Operator Value

      Additional Config

      ▸ Generated Code Preview
      
      
      Configure inputs and click Generate Code