Using digital twins to develop system control logic

Designing, developing and building a groundbreaking project that pushes the boundaries of renewable technologies presents numerous challenges. Those can range from figuring out how to adapt existing tech for a new use or installation, to translating an idea from a blank sheet design to a finished solution. There’s another challenge too – how do you write control software, develop the system architecture, and test everything while your project is still being built?
That’s especially true when it comes to complex projects that have a strict delivery schedule and where, in some cases, there may even be penalty clauses that are triggered by non-contractual run-ons. This can be true across a wide array of projects, from commercial facilities to manufacturing plants to a private residence or an ocean-going vessel.
It’s a challenge that a team of software developers, in collaboration with XRG Simulation GmbH, has been tackling, using as its basis a key system that has been designed for the 69-metre sailing yacht Zero project. The vessel aims to operate by harvesting power solely from renewable energy sources rather than using diesel or alternative fuels, but to achieve this the project has required considerable research and development because many of the proposed solutions have never been applied to a yacht before.
This creates an additional problem, because alongside the demands of a tight build schedule, both the lack of availability of a complete system and high cost mean that real-time physical testing – a Hardware-in-the-Loop (HIL) approach – is not practical.
So how do you develop the control logic needed to run a complex system when that system has yet to be built? The answer is to create a dynamic model of the physical system in a virtual environment – in effect, a detailed simulation which acts and reacts just as the system would in real life, giving the team the opportunity to develop, test and troubleshoot their solution so it’s ready for implementation when the physical system is ready to come on-stream. It’s called a Software-in-the-Loop (SIL) approach – essentially, creating a digital twin that enables the control logic and the system’s operational response to be validated so it can be ported to the real system during commissioning.
Energy balance
Sailing yacht Zero is taking an innovative approach to energy harvesting, storage, distribution and management, relying on advanced technologies that balance energy generation, storage and demand. With Foundation⁰’s studies highlighting how climate control on a yacht typically can account for up to 50 percent of a yacht’s energy use, effective thermal management will be critical to maximise efficiency and minimise energy demand on board.
Alongside incorporating cutting edge insulation design and materials, and a heating, ventilation and air-conditioning (HVAC) system that includes using the mast for natural ventilation and adiabatic cooling, a Thermal Harvesting and Recovery System (THRS) is also being developed to deliver further energy savings. It is this system that the Foundation⁰ and XRG Simulation teams have been exploring using an SIL approach to predict system function and develop its control logic.
The THRS aims to reduce electricity consumption by harvesting and deploying heat energy. It harvests the heat energy in a number of ways, via custom photo-voltaic thermal panels installed on the yacht’s fixed biminis and through heat recovery from the propulsion system and electrical components – heat which otherwise would not just be wasted but could actually contribute to temperature build-up in the interior, requiring more energy to be spent on climate control.
The recovered heat will be stored in thermal batteries that use a phase change material (PCM) and will be used for heating the domestic hot water supply, as well as in an adsorption chiller that supplies cool water to wall and ceiling panels throughout the yacht, further reducing load on the HVAC system.

Model making
To create their model, the team is using Modelica – an open source, object-oriented programming language designed to model complex physical systems. Modelica can combine components of differing types into a complex system model, and there are already large libraries of pre-configured components, making it easy to combine common mechanical, electrical, hydraulic or thermal components such as pump, motor, gearbox and control module into a system chain.
“Our THRS model is a digital twin in the truest sense of the word – a mechanistic digital model,” says Boudewijn van Groos, tech lead and software developer at Foundation⁰. “I think we have a somewhat novel way of approaching it with Modelica. We’re treating the simulation – and packaging it – like a black box that is identical to the programmable logic controller (PLC) that will be reading the sensors and controlling the actuators on board. Essentially, our control logic doesn’t know anything more than there’s some system that’s sending it sensor values.”
The advantages are clear, allowing the team to work on the software that will control the THRS while the actual physical systems are still being developed and installed. “We don’t need to get a physical system in the office, then write the code and test it,” Van Groos explains. “We build it in software so that when we write the code that will control the system we have a virtual black box to test it against. In this way we prevent regression bugs by getting a representative digital environment in which we can run our code and test everything before the yacht and its systems are actually finished.” Once completed, transition to the physical system is simple – the team will just replace the dynamic model with the yacht’s actual input/output interfaces.
While straightforward on paper, harvesting, recovering, storing and consuming the heat energy requires an intelligent control system that not only can efficiently manage the THRS but can also respond to other systems on board, integrating inputs such as trip itineraries, weather forecasts, and consumption profiles, while also providing feedback for the crew, for example suggesting optimal times for energy-intensive activities such as laundry.
The system is divided into functional submodules such as the high temperature circuit for harvesting and storage, the chiller circuit for chilled water production and the hot water circulation circuit for conditioning of tap water, each having its own control logic to deliver basic functionality. A central control system coordinates the modes and setpoints across the submodules based on current or forecasted onboard conditions. The controller is being implemented in Python, which will also be used in the real system. This also has the advantage of fitting neatly with the SY Zero project’s focus on open access as, unlike many conventional tools, it is not commercial.

To create the THRS model, the team used components from open-source Modelica libraries and XRG’s HVAC Library, which is designed for fast and robust simulations of thermo-hydraulic and air distribution systems. The model integrates PVT panels, thruster cooling, PCM storage, adsorption chiller, heat pumps, multiple heat exchangers, valves, pipes and pump that was exported into a functional mock-up (FMU). This FMU is independent from the original Modelica simulation environment while parameters like controller settings that can still be changed. In this case it was combined with a Python wrapper enabling the FMU to communicate with the control module. As the team notes, one of the key aspects of the setup is the ability to exchange the real system with the simulation model. This means that the control code is fully unaware of that difference.
To demonstrate the method of building the system in Modelica, the team has produced an extensive case study focusing on the modelling of a thruster component (which forms a part of the THRS). “The paper we wrote with XRG Simulation describes specifically the Modelica-driven development of the thermal control system for a zero-emission yacht,” confirms Van Groos. “It goes into the process of how we set it up.”
Stefan Wischhusen, head of building simulations at XRG Simulation, explains: “A challenging aspect is that the Modelica model must always provide robust and reliable outputs for all inputs during testing and it needs to execute much faster than in real-time. We cannot verify all combinations of inputs the FMU may see during testing, and this is why it is important to have both an accurate and robust system model. The HVAC library successfully carries all our expertise we gained over the years in building projects and casts it seamlessly into a new field of application: naval HVAC systems.”

First presented at the 16th International Modelica Conference last September in Lucerne, Switzerland, the paper breaks down in detail the team’s approach, showing how real inputs, representing control values or boundary conditions, and outputs representing sensor values that match the real system can be applied to test the system and predict outcomes.
This enables the design of a control system even though the real system has not yet been finalised, while also making it possible to assess scenarios that are quite difficult to evaluate in the real world. The advantages are clear – when a project has a tight schedule, modelling the system in this way means the time taken to implement the control parameters of the real system can be reduced. That can have huge benefits, not only for the timely completion of a project but also for reducing costs spent on physical testing.