Nicholas Reed's NoteBook - cps-vip/cps-cosimulation-env GitHub Wiki

Fall 2024


September

Week of 9/08/2024

  • Set up WSL2 on my machine so that I can contribute to the project.
  • Installed Nix using the instructions on the README.
  • setup the Nix development environment.
  • Cloned the github repository onto my machine and pulled all the listed submodules
  • Attempted to build HELIX and Gridlab-D; however, ran into an issue while attempting make all-install

Screenshot (167)

Week of 9/15/2024

  • Resolved issue with building HELICS and Gridlab-D.
  • If you are using wsl2, make sure you have enough memory.
  • Change the configuration settings so that only 1 core is building HELICS and Gridlab-D

Week of 9/22/2024

  • Did some research on substation devices, focusing on fault tolerance.
  • Took a look at the repository to understand the code. Noticed that there is no implementation for circuit breakers.
  • Refreshed some of my Python Knowledge.

October

Week of 9/29/2024

  • Worked on the Research paper this week. Mostly focused on research for device models.
  • Was super busy and could not contribute much to the project, so I looked over some of the source code in the repo.
  • Did a little more research on circuit breakers.

Week of 10/06/2024

  • Did some work on the midterm presentation.
  • Briefly reviewed some python, HELICS, and Gridlab-D.
  • Here are the resources I used: Python HELICS Gridlab-D

Week of 10/13/2024

  • Took a look through the repository and did research on substation devices.
  • Here is the website I used for introducing myself to substation devices Quick Overview
  • I noticed that many of the devices in the repository have not been completed. For example, the switchgear at bay level is completely empty.
  • Additionally, I was also a little confused about the organization of the models. There are two files named circuit_breakers.py in the bay level and process level.
  • It might be worth it to consider re-organizing the src directory.

Week of 10/20/2024

  • Attended this week's meeting. The device modeling work in the repo was mostly done by someone named Xin Zhao. I will look over his notebook this week.
  • Ended up not doing that much this week. I got super busy with my other courses.
  • To-Do:
  • Look through Xin Zhao's notebook.
  • Start refactoring the src directory
  • Begin drafting the new device models

Week of 10/27/2024

  • Attended this week's meeting.
  • Looked through Xin Zhao's notebook during class, specifically the section labeled "Substation System Layers"
  • I think the base classes for every device should be in the device_base directory. Some of the system layers have contradicting information, such as the duplicate circuit_breaker.py in the bay level and process level.
  • To-Do:
  • Look through Xin Zhao's notebook.
  • Start refactoring the src directory
  • Begin drafting the new device models

November

Week of 11/03/2024

  • Could not attend this week's meeting.
  • Did a little bit of research on switch gears since that is the device we decided on.
  • Read through the Wikipedia: SwitchGear Wiki

Week of 11/10/2024

  • Could not attend the meeting this week.
  • Worked on drafting a python class for the switchgear.
  • Here is what I drafted:
class Switchgear:
    def __init__(self, name, max_voltage, max_current):
        self.name = name
        self.max_voltage = max_voltage
        self.max_current = max_current
        self.isolated = False
        self.circuit_status = "CLOSED" 
        self.fault_detected = False

    def control_circuit(self, action):

        # action refers to opening or closing the circuit 

        if action.upper() in ["OPEN", "CLOSE"]:
            self.circuit_status = action.upper()
        else:
            print("Invalid action. Use 'OPEN' or 'CLOSE'.")

    def protect(self, voltage, current):
        
        # A fault is detected in two situations:
        # - The current exceeds the max current
        # - The voltage exceeds the max voltage

        if voltage > self.max_voltage or current > self.max_current:
            self.fault_detected = True
            self.control_circuit("OPEN")
        else:
            self.fault_detected = False

    def isolate(self, status):
        
        # status is a boolean value: 1 = isolated, 0 = not isolated

        self.isolated = status

Week of 11/17/2024

  • Briefly discussed the final presentation at this week's meeting.
  • Edited some of the Device slides for the final presentation.
  • For the most part, the device modeling slides for the final presentation are the same as the midterm presentation.
  • The only difference is the addition of the transformer and switchgear devices.

Week of 11/24/2024

  • We did not meet this week for any meetings since the only thing left is the final paper.
  • Not really any work done this week. We will most likely begin work on the final paper next week before it is due.
  • To-Do:
  • Begin drafting the new device models
  • Finish the final paper before 12/04/2024

December

Week of 12/02/2024

  • This week's focus was on getting the final paper done.
  • For my contribution, I worked on the subsection "Substation Device Modeling" in the Research Sections. I mostly focused on the future plans of the Device Modeling team.
  • In the future, we want to continue developing more device models and complete the currently unfinished ones.
  • To-Do:
  • Finish building the incomplete device models.
  • Continue building more devices.

Spring 2025


January

Week of 01/19/2025

  • Focused on the Kickoff Presentation this week. The goals for the Device modeling team have remained the same: Build more Python classes, continue the ML work, and begin integrating DNP3 with the Networking Team.
  • I have a new laptop, so sometime this week, I need to set up the Nix environment, build HELICS, and build Gridlab-D.
  • To-Do:
  • Set up Nix environment, HELICS, and Gridlab-D.
  • meet with the rest of the team to decide which devices we want to model.
  • Begin plans to integrate DNP3 with the current device models.

Week of 01/26/2025

  • Installed nix on my system, but running into problems with nix develop.
  • Could not do much else this week, was super busy with other courses and interviews.

Week of 02/02/2025

  • I updated my OS over the weekend and could no longer use the nix command on the terminal.
  • Re-installed Nix on my machine and ran into similar issues with Nix develop. If I attempt Nix develop in the cloned repository, I get the following message:
Screenshot 2025-02-06 at 4 53 15 PM
  • Attended this week's meeting. We decided to get an early start on the paper and discussed the Logging library we're using and the device that we will build.

February

Week of 02/09/2025

  • I was not able to attend class this week. Got super busy with interviews.
  • Attended the meeting this week. We went over our progress on the Paper.

Week of 02/16/2025

  • Finished setting up the co-simulation environment and nix. This issue was the name of my directory, "GT Courses"
  • nix was splitting up the file path since there was a space between GT and Courses. The fix was to rename the directory to "GT_Courses"
  • Got some work done on the research paper. Mostly focused on updating the introduction to include our plans to continue building more device models and begin integrating DNP3 and Monitoring.
  • To-do:
  • Set up Nix environment, HELICS, and Gridlab-D.
  • meet with the rest of the team to decide which devices we want to model.
  • Begin plans to integrate DNP3 with the current device models.

Week of 02/23/2025

  • Was not able to attend meetings this week due to interviews and other courses.

March

Week of 03/02/2025

  • Made it to this weeks meeting. I decided to switch to the Networking team.
  • Downloaded the components for the VM and downloaded Qemu. Got the VM working and dnp3 seems to be working. Read through the README inside of default_example, will make sure to go through the other README files in the other directories.
  • looked through the README file in c_api_example and installed the python extension module. Problems with running run_fork.py
Screenshot 2025-03-07 at 12 06 03 AM
  • Took a look at the ctypes_example directory and read the README. There was not a "main" directory to cd into.
  • Managed to fix the issue with running the python script. I was forgetting to launch the virtual environment, so the module was not there.
  • Attended this weeks meeting. We are getting closer to integrating DNP3 with the device models. Networking has a couple tasks that must be completed before this can happen.
  • I am currently working on exposing methods in outstation.c, here is the documentation that I will be using: Documentation
  • To-Do:
  • expose outstation methods in the c api (outstation.c).
  • Go through Kanden's Wiki and read through all the documentation.
  • Go through the ReadMe files on c_api_example and ctypes_example

Week of 03/09/2025

  • Attended class this week and worked on exposing the C methods. Did some research on the python C extension module, which is what we are using on the Networking Team.
  • I briefly read through the python documentation on C extension: Documentation
  • I read through Kaden's notebook and familiarized myself with the extension module based architecture. I also read through his New Member Guide to get a better idea of what to start on.
  • I briefly reviewed some of my notes from CS 2110 to remember the OSI model and TCP basics. I also looked through the rest of the DNP3 documentation: Documentation
  • To-Do:
  • Go through Kanden's Wiki and read through all the documentation.
  • Go through the ReadMe files on c_api_example and ctypes_example.
  • expose outstation methods in the c api (outstation.c).

Week of 03/16/2025

  • This week was spring break, didn't really do anything.

Week of 03/23/2025

  • Updated my OS, so I had to re-install nix.
  • Was not able to attend class this week, but I attended Friday's meeting.
  • Continued to read through the documentation on C extension. I noticed that in the current state, the outstation does not add the module to the initialization table. I added the following code to the outstation:
int main(int argc, char *argv[]) {

    PyStatus status;
    PyConfig config;
    PyConfig_InitPythonConfig(&config);

    /* Add a built-in module, before Py_Initialize */
    if (PyImport_AppendInittab("dnp3_extensions", PyInit_outstation) == -1) {
        fprintf(stderr, "Error: could not extend in-built modules table\n");
        exit(1);
    }

    /* Pass argv[0] to the Python interpreter */
    status = PyConfig_SetBytesString(&config, &config.program_name, argv[0]);
    if (PyStatus_Exception(status)) {
        goto exception;
    }

    /* Initialize the Python interpreter.  Required.
       If this step fails, it will be a fatal error. */
    status = Py_InitializeFromConfig(&config);
    if (PyStatus_Exception(status)) {
        goto exception;
    }
    PyConfig_Clear(&config);

    /* Optionally import the module; alternatively,
       import can be deferred until the embedded script
       imports it. */
    PyObject *pmodule = PyImport_ImportModule("dnp3_extensions");
    if (!pmodule) {
        PyErr_Print();
        fprintf(stderr, "Error: could not import module 'dnp3_extensions'\n");
    }
  • I am not 100% sure if this is necessary, but will check in with Kaden. This should allow the PyInit_outstation() function to be called automatically, which should initialize the module.
  • Trying to understand compilation and linkage since this is the last step before using the extension. Currently reading this resource: Source
  • In the meantime, the Device Modeling team is almost done with their models, so the networking team is looking to get a working instance of DNP3. Currently, I am tasked with exposing callback functions. More specifically, the Outstation receives SELECT and OPERATE requests from the Master. The methods that handle this in the extension module need to be exposed python so that the Device-Modeling team can use these methods in a high-level language.
  • To-Do:
  • continue working on exposing methods in the outstation.
  • Begin writing methods in the C extension module to set callback methods.

Week of 03/30/2025

  • This week I attended class and The meeting. Could not contribute too much at the beginning of the week because of another course, but I will make sure to get some work done over the weekend.
  • Ok, so it turns out that the extension module is completely set up. So ignore everything from last week. Checked in with Kaden to get a better idea of how to approach the callback methods. I will try to understand how each of the call back methods work and how to write methods to set these call back methods.
  • So far I have been using these resources to catch up on Python Object calling, Wrapper functions, and Function pointers: Stackoverflow Post 1 Stackoverflow Post 2 Python API Documentation
  • From what I understand, for these functions to be used in python, they need to be called in wrapper functions. These wrapper functions will call the Control Handler methods and return a python object, allowing the functions to be used in the C extension module. I have written an outline of these wrapper function and will try to figure out how to implement them. Here is what I have so far:
Screenshot 2025-04-11 at 8 47 49 AM
  • To-Do:
  • continue writing methods in the C extension module to set callback methods.

April

Week of 04/06/2025

  • Attended class and this weeks meeting. We have run into an issue with writing the callback methods. Attempting to call any of the methods in python lead to seg faults. Additionally, Kaden has run into numerous issues with race conditions and deadlocks.
  • It looks like the issue is too complex to solve at the moment, since we do not have that much time left in the semester. So I will focus the rest of the semester towards the final presentation.
  • Additionally, Kaden has suggested that the issues may be so severe that we might need to find another way to call DNP3 functions in python. We could potentially use cTypes, although this would not be as good of a solution as the C extension module. We could also directly call the functions from Rust, but I would need time to learn Rust.
  • To-Do:
  • Meet with the rest of the team and discuss solutions to the python extension module.
  • Work on the final presentation slides

Week of 04/13/2025

  • The beginning of the week was spent on the final presentation slides. I mostly added myself to the networking slides and updated the tasks that I focused on, which was mostly trying to expose methods in the outstation by writing callback functions.
  • There was not that much to add to the Networking section since we ran into that bug, so unfortunately most of the work that we are presenting will be the same thing from last time, with some additional updates.
  • Attended the Final Presentation in class this week. The only thing left in the semester is the final paper, which will likely be discussed during the meeting.
  • Attended this weeks meeting. Our main goal for the final paper is to condense it, since it is starting to get super long (about 10 pages at the moment).
  • To-Do:
  • Meet with the rest of the team and discuss solutions to the python extension module.
  • Work on the final presentation slides
  • Begin working on the Final Paper.

Week of 04/20/2025

  • Not that much happened this week besides working on the final paper. Our primary goal was to condense the paper since it was getting close to being 10 pages long.
  • I made some contributions to the "integrating DNP3" subsection of the paper, but otherwise focused on condensing the content in the paper.
  • I also got my peer evaluations done and requested another permit for VIP. I accidentally requested a permit for the 1 credit VIP bit I need one for 2 credits.
  • To-Do:
  • Meet with the rest of the team and discuss solutions to the python extension module. (Will have to wait until next semester)
  • Work on the final presentation slides
  • Begin working on the Final Paper.

Spring 2026

January

Week of 01/12/2026

  • First week of classes and first week back from my fall internship
  • Filled out the Sub-team preference and welcome quiz.
  • Registered for time conflict section for the course.

Week of 01/18/2026

  • I've been looking through Kaden's Notebook to get a better idea of where the Networking team left off at. I have also looked through the repo, specifically the recent commits to the Piperr and Networking_team branches.
  • Set a meeting time for the team.

Week of 01/25/2026

  • Met with Hubert and discussed our plans for the semester. We began working on the kickoff presentation and I showed him how to get started with setting up his dev environment.
  • After looking through the previous semester's slides, we decided to primarily focus on the networking and device subteam's outstanding work. This is due to the formation of the Security team, as well as my previous experience working on Networking.
  • Since I am working remote, I recorded audio for the slides that I read off of.
  • Completed the kickoff presentation and submitted it.
  • To-Do:
  • Finish the Kickoff presentation and submit.
  • Make sure both me and Hubert have our development environments setup.
  • Begin working on Merging the Device Subteam's repos.
  • Decide on whether we want to use Docker or Nix for standardized build environment.

February

Week of 02/01/2026

  • Met with Hubert for our weekly meeting. We are currently focused on making sure our development environments are properly set up. Hubert has an Ubuntu VM installed on his machine and I am using MacOS.
  • As of right now, my development environment is the same as it was in Spring 2025. I am still using the Debien VM for the networking tasks. However, the networking team moved over to a docker container last semester, so I will focus on switching over to that.
  • To-Do:
  • Make sure both me and Hubert have our development environments setup.
  • Read Docker setup instructions (Kaden's last git commit in Networking_team branch).
  • Begin working on Merging the Device Subteam's repos.
  • Decide on whether we want to use Docker or Nix for standardized build environment.

Week of 02/08/2026

  • Met with Hubert this week, although I was pretty busy so not that much work got done.
  • Helped Hubert set up docker and get his dev environment up and running. I went through the setup process again and updated all of my package management software. Goals remain the same.
  • To-Do:
  • Make sure both me and Hubert have our development environments setup.
  • Read Docker setup instructions (Kaden's last git commit in Networking_team branch).
  • Begin working on Merging the Device Subteam's repos.
  • Decide on whether we want to use Docker or Nix for standardized build environment.

Week of 02/15/2026

  • Met with Hubert this week and we prepared the midterm slides. We also came up with our plan for merging the branches.
  • Right now the Networking_Team branch and the piperr branch are the two most similar branches, they only broke off a couple months ago. So those two branches are what we're going to be focusing on for now. Piperr has the most up to date DNP3 code, while Networking_Team has the most up to date Build environment (Docker files) and directory structure.
  • Here are the recent commits for Networking_Team:
Networking_Team
  • Here are the recent commits for piperr:
piperr
  • When we merge these two branches, we will keep the build environment and directory structure from Networking_Team, while also keeping the DNP3 code from piperr.

  • To-Do:

  • Read Docker setup instructions (Kaden's last git commit in Networking_team branch).
  • Begin working on Merging the Device Subteam's repos.
  • Decide on whether we want to use Docker or Nix for standardized build environment.

Week of 02/22/2026

  • Me and Hubert met and finalized our Midterm slides. We added two more slides to the presentation for a more clear explanation on the branch merging tasks. Since the presentation got delayed by a week, we had more time to refine the slides and organize them.

  • I recorded my voice over for some of the slides and embedded them into the presentation.

  • Did the peer evaluation.

  • This week me and Hubert began working on merging the branches, starting with the Networking_Team and piperr branches. We will start by opening a new branch from Networking_Team, called "Device_Modeling" (This is because Networking_Team has the most up to date file structure). Then we will merge the piperr branch into Device_Modeling.

  • I am also showing Hubert how to use Git. I showed him the git documentation for reference: Git Learning Website

  • To-Do:

  • Read Docker setup instructions (Kaden's last git commit in Networking_team branch).
  • Create new branch for device modeling team work (device_modeling_team).
  • Merge piperr and Networking_team branches into device_modeling_team.
  • Merge device_modeling_subteam01 branch into device_modeling_team.

March

Week of 03/01/2026

  • This week I was not able to do much work due to exams. Me and Hubert were also not able to meet due to unforeseen circumstances. I looked at the recent commits in the piperr and Networking_team branches to try and get an idea of how I can merge the two.

  • To-Do:

  • Read Docker setup instructions (Kaden's last git commit in Networking_team branch).
  • Create new branch for device modeling team work (device_modeling_team).
  • Merge piperr and Networking_team branches into device_modeling_team.
  • Merge device_modeling_subteam01 branch into device_modeling_team.

Week of 03/08/2026

  • Me and Hubert met this week and began working on merging the repos. The first thing I did was create a new branch, this one is called "device_modeling_team" and will be the new branch where all of the device modeling work will take place in. The device_modeling_team branch is a duplicate of the Networking_team branch; however, I made sure to add submodules for HELICS and gridlab-d:
Screenshot 2026-03-11 at 5 39 59 PM
  • After that, we spent some time trying to build the docker image. All of this was pretty easy since the steps are laid out in the README, and we were able to successfully run the docker container. However, we ran into some errors when trying to run the setup script. This was done on Hubert's Ubuntu VM since I use apple silicone and Kaden mentioned there being issues with that hardware.

  • To-Do:

  • Read Docker setup instructions (Kaden's last git commit in Networking_team branch).
  • Create new branch for device modeling team work (device_modeling_team).
  • Merge piperr and Networking_team branches into device_modeling_team.
  • Merge device_modeling_subteam01 branch into device_modeling_team.
  • Get Raspberry Pies working

Week of 03/15/2026

  • Me and Hubert were not able to meet this week due to exams and scheduling issues. I was also not able to complete any work this week.
  • To-Do:
  • Merge piperr and Networking_team branches into device_modeling_team.
  • Merge device_modeling_subteam01 branch into device_modeling_team.
  • Get Raspberry Pies working

Week of 03/22/2026

  • This was spring break, so I did not do any work on the project.

Week of 03/29/2026

  • Me and Hubert met to work on the project. I continued working on merging the branches while he was working on getting his Raspberry Pie working. Hubert was running into an issue, every time he tried entering the password for the Raspberry Pie he got the following message: ping: google.com: Temporary failure in name resolution
  • Since we decided to use the docker build environment, we needed to pull the all of the database methods and DNP3 code from Piperr. Since we split our branch off from the Networking Subteams work, the Docker build environment is already there:
Screenshot 2026-04-22 at 5 38 41 PM Screenshot 2026-04-22 at 5 47 18 PM
  • I used git cherry-pick to integrate all of the changes from Piperr into the device modeling branch and no errors showed up on my end:
git cherry-pick d425252
git cherry-pick 2c97a33
git cherry-pick f8e3dc4
  • To-Do:
  • Merge piperr and Networking_team branches into device_modeling_team.
  • Merge device_modeling_subteam01 branch into device_modeling_team.
  • Get Raspberry Pies working

April

Week of 04/05/2026

  • Met with Hubert and we began making plans to integrate the changes in the Device Modeling subteams branch into ours (device_modeling_subteam01). This is the trickiest part of the process, as the device modeling subteam branch has an outdated build environment and a completely different directory structure. My approach is to manually go through both branches and backtrack to the point where they split off from each other. From there, I will try to manually review both code bases and merge them together.
  • After looking through both codebases, I decided to start off with updating the documentation, since it would only require making a few changes and simple git commands. Adding the RTU is also pretty simple since it was only recently added to the device modeling subteam. Using git cherry-pick, I completely replaced all of the documentation in the our git branch with the progress made by the device modeling subteam.
Screenshot 2026-04-23 at 9 31 04 AM
  • The next step is going to be integrating the changes to the process level. This includes the base process device class, as well as some of the transformers (see the above screenshot). This is where it becomes more tricky since the directory structure has changed.
  • We are also continuing to have issues with the Raspberry Pi, as well as with the Docker environment. Therefore, we have not been able to build and test the simulation environment.
  • To-Do:
  • Merge device_modeling_subteam01 branch into device_modeling_team.
  • Get Raspberry Pies working

Week of 04/12/2026

  • This week Hubert managed to get the Raspberry Pi working on his machine. However, when we tried testing the simulation environment, we ran into more errors. More specifically, we ran into Github permissions errors when Hubert tried to clone the repo onto the Raspberry Pi. Unfortunately, we will likely have to skip testing.
  • The focus this week is on integrating the base process device class and the transformers. We needed to ensure that we merge the changes made from the device modeling team while not overwriting the changes to the build system. To accomplish this, I used the specific commit hashes to pull the changes from device modeling, while leaving the current directory structure and build system. There were no merge conflicts, and the changes were pushed to github:
Screenshot 2026-05-08 at 3 04 44 AM
  • After completing the merge, I went through each of the files in the codebase to make sure everything was correct and noticed that the process device base class is importing a module that does not exist in the same file path anymore. In the previous directory structure, the DNP3 logic was inside of the src directory, however, it is now separate:
Screenshot 2026-04-23 at 10 01 41 AM
  • Since we can't test anything right now, it is hard to see if there are any other situations like this one; however, this is the only one I saw when going through the codebase. The only thing left for this semester will be working on the final presentation.
  • I also updated the README so that the instructions are a little more clear.
  • To-Do:
  • Merge device_modeling_subteam01 branch into device_modeling_team.
  • Get Raspberry Pies working (Will be pushed to next semester).
  • Finish the Final Presentation.

Week of 04/19/2026

  • This week we met and began working on the Final Presentation slides. The most important task to complete next semester is to get a working build and test the simulation environment. There might be some debugging needed since we merged the branches without doing any tests. From there, the next task is to finish the python extension library and integrate DNP3 into the device models, as well as finishing the RTU.
  • For completing the Python Extension library, it would be best to look at Kaden's last notebook entry, as he has a lot of detail on what needs to be done. I would also recommend completing this first since finishing the RTU will likely take an entire semester.
  • After finishing the slides, I submitted them and Hubert presented.
⚠️ **GitHub.com Fallback** ⚠️