Electric Power Flow Modeling in Minecraft

The goal of this project is to enable the creation and use of realistic and accurate virtual reality models of electric power transmission, distribution, control, and usage scenarios for research and instruction purposes. To accomplish this, we have created a Minecraft mod called Electric Blocks.

= Problem Definition = Our project is defined by several problems. The core issue is to develop software that allows users to model electrical power flow. The software must model power flow realistically enough to enable quality education and research. Additionally, the software must work in a virtual video game environment and must be easy to use.

Background
Minecraft is a 3D/VR video game that enables the creation of complex virtual worlds. The block based nature of the game makes it very easy for players to build nearly any structure. This approach has made the game very popular and also easy to modify. There are thousands of mods which do everything from adding new animals to flight simulators and much more. There are several mods that already exist which attempt to mimic power flow. Unfortunately, these do not model the operation/control of electrical systems in a way that is realistic enough to enable quality research and education in power systems. This is why we made Electric Blocks.

Value Proposition
Traditional tools used in the design and simulation of electric power flow networks require a highly technical understanding of power flow behavior, and are not readily accessible to learners due to their complex interfaces and results that are not easily interpreted. Our solution, Electric Blocks, is a Minecraft mod to attract those who are interested in designing and playing with power systems through the simple and familiar interface of Minecraft.

This project's value is primarily derived from its speed and ease of use. Electric Blocks works great as an educational tool as users can build simple power systems in mere seconds and get feedback. This project also has value for power flow engineering. This mod allows for engineers to work collaboratively in real-time to prototype and test power flow systems.

= Design Process = Our design process began in early September of 2020 and was focused entirely on solving our problem definition. Most of our overall design decisions were finalized by the end of September, but we continued to tweak the design as new discoveries were made.

Initial Design
In the initial documentation provided to us, our client outlined several suggestions on how to approach this project. They suggested the using Minecraft or Minetest as the platform for hosting our software. We could then use MCreator or the Minetest Lua API for programming the mod. Our client also noted that we should not attempt to write our own power flow simulation software and should instead use other software libraries for this task. This design consideration was critical as realistic and accurate simulation was a primary goal of this project. Our client had experience with an electrical power distribution system simulator called OpenDSS and suggested we look into using this together with DSS Python or some other API interface. We would then make calls to the interface from the mod to OpenDSS to perform power flow simulations and update the game state appropriately. This left us with an initial development stack that looked like this:



We could choose to design our mod using Minecraft or Minetest. We would then use their corresponding mod creation tools to add blocks into the game based on power engineering elements such as lines, loads, transformers, generators, etc. We would then use information from the game to make calls to OpenDSS using a compatibility layer. OpenDSS would then run a power flow study and return the results to our mod. Finally, the Electric Blocks Mod would use those results to inform the player and modify the game state.

While this design seemed like a good overall solution, we quickly realized that we had a lot of issues that we would need to resolve before proceeding. Should we use Minecraft or Minetest as the basis for our mod? How would our mod communicate with the simulator and is a compatibility layer needed to facilitate communication? How would this architecture work in singleplayer versus multiplayer settings? How would the mod translate the game state into a form that the simulator could understand? These are all questions that we had to do in-depth research on before we could arrive at a final design.

Project Learning
While our initial design plan was solid, we still had many issues that we needed to research before moving forward.

Should we use Minecraft or Minetest as the base game for our project? These were the two possibilities presented to us by our client. Both our team and client agreed that the block based virtual worlds of Minecraft and Minetest were an ideal sandbox environment for us to use as the basis for our mod, but which one should we use? Minecraft is substantially more popular and has an installation process that is familiar to many players. However, Minetest was designed from the ground up to support mods which provides several benefits. The Minetest Lua API is thoroughly documented and easy to use. Mods are contained and ran exclusively on the server side with code and media being automatically transferred to the client upon connection. This means that the programmer doesn't have to worry about writing code for both the client and server side in Minetest and players don't have to take any steps to use the mod if they can connect to a server running it. The benefits of Minetest are substantial, but we ultimately decided to target Minecraft as our base game instead. The target audience for this software is educators/students and engineers. This audience is largely already familiar with Minecraft and how to mod the game. If we went with Minetest, nearly anyone who wanted to use it would need to install this new piece of software. By choosing Minecraft, there would be more programming work involved, but we would be taking advantage of the knowledge, intuition, comfort, and excitement that many people have regarding Minecraft.

What modding platform should we use to develop the mod? The initial documentation provided by our client suggested that we use a development environment called MCreator to develop the mod. MCreator is designed to simplify the development process and make mod creation easy. While this seems like an appealing tool, further research made us decide against using it. MCreator is a closed system that simplifies code and prevents you from directly accessing Minecraft. While it does make the mod creation process easier, this tool seems to be best suited for individuals who are learning software development and not for those who are creating complex mods. MCreator is actually based on Forge which is the defacto standard modding platform for Minecraft and so that is what we decided to use. Forge hooks into Minecraft and provides us access to the game and an API for modifying game behavior.

How would our mod communicate with the simulator and is a compatibility layer needed to facilitate communication? Our client initially suggested that we use DSS Python to access API bindings for OpenDSS and that we could use shared files for communication. We quickly ran into issues with using this approach. While DSS Python is cross-platform compatible, it requires that you have the OpenDSS COM interface file compiled to target your specific operating system. OpenDSS is built for Windows and only unofficial builds are available for other platforms. OpenDSS is not cross-platform compatible. This makes installation more difficult and would require us to write platform specific code for interfacing with OpenDSS. We are using Java to write the mod and OpenDSS does not offer a Java binding. Additionally, the OpenDSS COM interface doesn't provide any functionality for building a power network and requires that you provide it with a file in the form of a DSS script. All these issues meant that using OpenDSS for simulations was not practical for us or our users. Our team concluded that we would need to use some other software for running the simulations and that we would likely need to develop some sort of compatibility layer which allows our mod to communicate with the simulation software. The exact way out mod communicated with the simulator would be dependent on which simulation software we ended up using.

Which power flow simulation software should we use instead? Since we decided that OpenDSS wasn't a good fit for our project, we scrambled to find a replacement. We realized that our replacement simulator had to meet several fairly stringent requirements to be useful for our project. Whatever we chose had to be: This meant that we couldn't use any common commercial software offerings. We concluded that PandaPower was the best software to fit our needs.
 * 1) Compatible with all major operating systems (Windows, Mac OS, Linux, etc)
 * 2) Easy to install
 * 3) Completely free and open source
 * 4) Able to run asymmetric three phase power flow

Validation
One of the core requirements of the project was that it must model power flow in an accurate and realistic manner. Rather than try to make the simulator on our own, we decided to use the PandaPower library. This library contains undergoes over 250 tests to ensure proper functionality. These tests include automatic validation against industry standard commercial software to ensure the implementation is correct.

Since our software is using a validated simulation system library, our client did not request any validation of our software. We have chosen to validate our software by taking a sample of the test networks used to validate PandaPower and build them in Minecraft. We will then compare results to ensure that the mod is behaving correctly.

= Development Timeline = Development began in mid September of 2020. Early development was focused on creating the communication system between Electric Blocks and EBPP and setting up the framework for how power system elements would be implemented in game. By early October of 2020, our team was able to successfully send data back and forth between the two programs.

Core Challenges
Visuals and texturing A secondary goal is to replace the current wire texture, a simple 16x16 image that reads "wire", with a more meaningful visual. A redstone block has the appearance of sand or dust on the ground. This is useful to the user, as it giving the illusion of less space being taken up, and adding visibility. This presents a unique challenge, because the model of the wire may must depend on the the existence or absence of other wire blocks surrounding it.

Client-Server model The computational side of the power flow simulation necessitated a library that solves the power flow problem. Inventing this library ourselves would be an immense task, so we chose to rely on PandaPower, a python library designed for this problem. Through some deliberation, we decided on implementing a socket connection between the Minecraft client, written in Java, which passes the network geometry to the custom python server, which computes the power flow, sending the results back to the client which can be viewed in-game by the player.

= Team Info = The team responsible for this project is called Electric Blocks. We are based in Moscow, ID and we are sponsored by the University of Idaho. For more info you can check out the links below:

Website: https://electricblocks.github.io

Github: https://github.com/electricblocks

Portfolio: https://drive.google.com/drive/folders/16nPXUH02bscp351xhRZSQRMSa27I0osg?usp=sharing