← Back to Technical Notes

29 September 2026 TN-004·Technical Note

Building a WECC REPC_C Plant Controller in PSCAD with FORTRAN and AI

First page of Building a WECC REPC_C Plant Controller in PSCAD with FORTRAN and AI

Technical Note TN-004

For more detail, figures and results - download the PDF

843 KB · 12 pages · PDF

Download PDF

PSCAD Model Creation with AI

As AI has got steadily more powerful, and my understanding of using it and applying it to power systems analysis and software has increased. The scale and application has started to become apparent. For myself, it has grown from being a fun novelty toy, to useful assistant for specific projects to something that is now actively saving me time and letting me take on challenges and projects I would have avoided.

In this use case I used Claude to connect to PSCAD via an MCP server and build a full model of the WECC REPC_C Plant Control system. This time round rather than trying to produce a model based on discrete components - I got Claude to implement directly using FORTRAN, and then build a test regime to make sure its implementation worked.

I have put a few of the results below, but most of the detail is in the PDF.

Next steps is to model the REEC_C electrical control systems, and then a whole aggregated model of a BESS!

1. Creating a Model

Building specific control models in PSCAD can be time consuming and a slow process, and for most engineers (myself included) we tend to build models using the available library transfer functions available, and wire it all together manually, with a few ports available for signal tracing.

But its easy to forget the PSCAD really is just a huge maths engine that uses FORTRAN, and many of the more complex models in the library are built entirely in FORTRAN. So the idea was to use Claude to connect to PSCAD using an MCP server and build a model direct.

2. Implementing the Model

One of the really powerful applications of this is the ability to upload a simple PDF / diagram of a control system, with all the transfer functions and then let Claude interpret it and turn it into a series of FORTRAN commands and implement it.

I had previously spent some time setting up and teaching Claude how to create submodules in PSCAD and set and define the parameters, so this bit was surprisingly easy. In retrospect, its actually a simple problem for an AI - a set of clearly defined maths functions for the control system and a decades-old programming language with lots of examples it has probably (hopefully) been trained on.

Interestingly it didn’t need any help to define the required ports or in definition of the parameters as externally settable values, and the whole implementation was smooth and hassle free.

3. Testing the Model

As with all control systems the challenging bit is testing it and proving that it works. This is hard in any system, but particularly in a FORTRAN code that I didn’t write. So in this case I did what I have done before and got Claude define, implement and evaluate a test plan and the output results – all as an agentic flow. I gave a few high level instructions of making sure it tested all the functions. It produced a test regime (below) and then checked with me for approval.

There were several expected results and a few surprises on the test regime. It autotuned and parameterised the system easily, and identified a few bugs in the responses where it didn’t quite meet the test regime – Claude happily updated and tweaked the code.

The unexpected behaviour was that Claude came up with a clever way of creating the tests. It developed an additional small submodule it called ‘SEQ’. Each SEQ box was a custom FORTRAN code that allowed definition of a series of ladder and test steps, rather than having to create a huge pile of the basic components from the library and chain them all together (which is what I would probably have done). It is a simple and elegant solution.

The other unexpected behaviour was that Claude, without being asked, decided to build a model of the system directly in Python, and then validate the PSCAD model against its own Python model!

4. Summary

This was a real fun application of PSCAD and putting things into a real use case. I have been meaning to benchmark the REPC_C model against and RMS simulation for a while, and also try out more complex model building in PSCAD. I was surprised at how smoothly this process ran and the longer term implications of this for power systems analysis and PSCAD can only be useful.

Download Technical Note 004 - Controller Modelling in PSCAD (PDF)

← Back to Technical Notes