{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Loading Functional Mockup Units"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Load required libraries:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import sys\n",
    "sys.path.append(\"../../cosimlibrary\")\n",
    "from cosimlibrary.loader import FMULoader"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Load the Mass Spring Damper FMU:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<cosimlibrary.loader.LoadedFMU at 0x18696ddb7f0>"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def logger(msg):\n",
    "    print(msg)\n",
    "\n",
    "msd1 = FMULoader.load(\"../../fmus/MassSpringDamper1.fmu\", \"msd1\", logger)\n",
    "msd1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Inspect FMU variables and parameters:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'v1': Real \"v1\",\n",
       " 'x1': Real \"x1\",\n",
       " 'der(v1)': Real \"der(v1)\",\n",
       " 'der(x1)': Real \"der(x1)\",\n",
       " 'fk': Real \"fk\",\n",
       " 'c1': Real \"c1\",\n",
       " 'd1': Real \"d1\",\n",
       " 'm1': Real \"m1\"}"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "msd1.vars"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Each var is associated with a unique value reference. For example:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "msd1.vars['fk'].valueReference"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Run a co-simulation with the above FMU."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "start_time = 0.0\n",
    "stop_time = 7.0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[OK] b'fmi2Instantiate: GUID=%s'\n",
      "fmi2Instantiate(instanceName=b'msd1', fmuType=1, guid=b'{ba983824-a6c5-471e-a8b7-db59c2e3a0fa}', resourceLocation=b'file:///C:/Users/clagm/AppData/Local/Temp/tmpltc7ndao/resources', callbacks=<fmpy.fmi2.fmi2CallbackFunctions object at 0x00000186A0D50748>, visible=0, loggingOn=1) -> 0x1869a823ae0\n"
     ]
    }
   ],
   "source": [
    "# Instantiate FMU\n",
    "msd1.fmu.instantiate(loggingOn=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[OK] b'fmi2SetupExperiment: toleranceDefined=%d tolerance=%g startTime=%g stopTimeDefined=%d stopTime=%g'\n",
      "fmi2SetupExperiment(component=0x1869a823ae0, toleranceDefined=1, tolerance=1e-08, startTime=0.0, stopTimeDefined=1, stopTime=7.0) -> OK\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Setup experiment\n",
    "msd1.fmu.setupExperiment(tolerance=1e-8, startTime=start_time, stopTime=stop_time)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[OK] b'fmi2EnterInitializationMode...'\n",
      "[OK] b'fmi2EnterInitializationMode: succeed'\n",
      "fmi2EnterInitializationMode(component=0x1869a823ae0) -> OK\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Enter Initialization Mode\n",
    "msd1.fmu.enterInitializationMode()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[OK] b'fmi2SetReal: nvr = %d'\n",
      "[OK] b'fmi2SetReal: #r%d# = %.16g'\n",
      "fmi2SetReal(component=0x1869a823ae0, vr=[4], nvr=1, value=[0.0]) -> OK\n",
      "[OK] b'fmi2SetReal: nvr = %d'\n",
      "[OK] b'fmi2SetReal: #r%d# = %.16g'\n",
      "fmi2SetReal(component=0x1869a823ae0, vr=[5], nvr=1, value=[1.0]) -> OK\n",
      "[OK] b'fmi2SetReal: nvr = %d'\n",
      "[OK] b'fmi2SetReal: #r%d# = %.16g'\n",
      "fmi2SetReal(component=0x1869a823ae0, vr=[6], nvr=1, value=[1.0]) -> OK\n",
      "[OK] b'fmi2SetReal: nvr = %d'\n",
      "[OK] b'fmi2SetReal: #r%d# = %.16g'\n",
      "fmi2SetReal(component=0x1869a823ae0, vr=[7], nvr=1, value=[1.0]) -> OK\n",
      "[OK] b'fmi2SetReal: nvr = %d'\n",
      "[OK] b'fmi2SetReal: #r%d# = %.16g'\n",
      "fmi2SetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[1.0]) -> OK\n",
      "[OK] b'fmi2SetReal: nvr = %d'\n",
      "[OK] b'fmi2SetReal: #r%d# = %.16g'\n",
      "fmi2SetReal(component=0x1869a823ae0, vr=[0], nvr=1, value=[0.0]) -> OK\n"
     ]
    }
   ],
   "source": [
    "# Set Parameters and Initial Values\n",
    "msd1.fmu.setReal([msd1.vars['fk'].valueReference], [0.0])\n",
    "msd1.fmu.setReal([msd1.vars['c1'].valueReference], [1.0])\n",
    "msd1.fmu.setReal([msd1.vars['d1'].valueReference], [1.0])\n",
    "msd1.fmu.setReal([msd1.vars['m1'].valueReference], [1.0])\n",
    "msd1.fmu.setReal([msd1.vars['x1'].valueReference], [1.0])\n",
    "msd1.fmu.setReal([msd1.vars['v1'].valueReference], [0.0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[OK] b'fmi2ExitInitializationMode...'\n",
      "[OK] b'fmi2ExitInitializationMode: succeed'\n",
      "fmi2ExitInitializationMode(component=0x1869a823ae0) -> OK\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Exit Initialization Mode\n",
    "msd1.fmu.exitInitializationMode()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[1.0]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=0.0, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[1.0]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=0.1, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.99]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=0.2, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.971]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=0.30000000000000004, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.944]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=0.4, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.90999]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=0.5, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.869941]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=0.6, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.824797]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=0.7, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.77546799]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=0.7999999999999999, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.722823911]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=0.8999999999999999, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.66768956]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=0.9999999999999999, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.61084040499]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=1.0999999999999999, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.552999269881]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=1.2, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.49483384423300003]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=1.3, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.43695496845099]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=1.4000000000000001, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.37991564180485105]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=1.5000000000000002, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.32421069813881603]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=1.6000000000000003, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.270277092421336]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=1.7000000000000004, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.21849474029421584]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=1.8000000000000005, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.1691878524555943]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=1.9000000000000006, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.12262670599789277]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=2.0000000000000004, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.07902979566140544]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=2.1000000000000005, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.038566309298587925]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=2.2000000000000006, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.0013588736154381068]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=2.3000000000000007, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.03251348159238261]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=2.400000000000001, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.06301219001557563]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=2.500000000000001, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.09013589278052553]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=2.600000000000001, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.11391710336882467]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=2.700000000000001, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.13441883397048865]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=2.800000000000001, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.15173122047829798]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=2.9000000000000012, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.1659681799956215]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=3.0000000000000013, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.17726413135642968]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=3.1000000000000014, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.18577080578120084]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=3.2000000000000015, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.19165417144993058]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=3.3000000000000016, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.19509149249397534]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=3.4000000000000017, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.19626853971911631]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=3.5000000000000018, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.19537696729680343]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=3.600000000000002, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.19261186671953068]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=3.700000000000002, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.18816950652701717]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=3.800000000000002, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.1822452636865597]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=3.900000000000002, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.17503175006487778]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=4.000000000000002, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.16671713516849848]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=4.100000000000001, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.15748366426110832]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=4.200000000000001, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.1475063690927722]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=4.300000000000001, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.13695196679865862]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=4.4, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.12597794104302867]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=4.5, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.11473179819497513]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=4.6, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.10335049022129665]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=4.699999999999999, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.09195999506303627]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=4.799999999999999, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.08067504451838897]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=4.899999999999999, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.06959898907757603]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=4.999999999999998, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.05882378873566049]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=5.099999999999998, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.04843011853716075]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=5.1999999999999975, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.038487577471154374]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=5.299999999999997, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.029054989326377033]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=5.399999999999997, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.020180784221365877]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=5.4999999999999964, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.011903449733592069]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=5.599999999999996, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[-0.004252040852381983]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=5.699999999999996, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.002753261638043014]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=5.799999999999995, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.009100554287949331]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=5.899999999999995, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.014785585056484588]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=5.999999999999995, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.019811107205286824]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=6.099999999999994, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.02418622128864399]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=6.199999999999994, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.027925712891612574]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=6.299999999999994, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.03104939312139786]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=6.399999999999993, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.03358144819928849]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=6.499999999999993, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.035549803838176075]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=6.5999999999999925, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.03698550943118202]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=6.699999999999992, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.03792214642650561]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=6.799999999999992, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.038395264627985023]) -> OK\n",
      "[OK] b'fmi2EnterEventMode'\n",
      "[OK] b'fmi2NewDiscreteStates'\n",
      "[OK] b'fmi2EventUpdate: Start Event Update! Next Sample Event %g'\n",
      "[OK] b'fmi2EventUpdate: newDiscreteStatesNeeded %s'\n",
      "[OK] b'fmi2EventUpdate: Checked for Sample Events! Next Sample Event %g'\n",
      "[OK] b'fmi2EnterContinuousTimeMode'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetDerivatives: #r%d# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2GetContinuousStates: #r%u# = %.16g'\n",
      "[OK] b'fmi2SetTime: time=%.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2SetContinuousStates: #r%d# = %.16g'\n",
      "[OK] b'fmi2CompletedIntegratorStep'\n",
      "fmi2DoStep(component=0x1869a823ae0, currentCommunicationPoint=6.8999999999999915, communicationStepSize=0.1, noSetFMUStatePriorToCurrentPoint=1) -> OK\n",
      "[OK] b'fmi2GetReal: #r%u# = %.16g'\n",
      "fmi2GetReal(component=0x1869a823ae0, vr=[1], nvr=1, value=[0.038441849545051435]) -> OK\n"
     ]
    }
   ],
   "source": [
    "# Time step\n",
    "H = 0.1\n",
    "\n",
    "# Will store current cosim time\n",
    "time = 0.0\n",
    "\n",
    "# Will store the timepoints\n",
    "t_range = [time]\n",
    "\n",
    "# Will store current position of the mass\n",
    "xs = [msd1.fmu.getReal([msd1.vars['x1'].valueReference])[0]]\n",
    "\n",
    "# Run cosim steps\n",
    "while (time+H)<=stop_time:\n",
    "    msd1.fmu.doStep(time, H)\n",
    "    time = time + H\n",
    "    xs.append(msd1.fmu.getReal([msd1.vars['x1'].valueReference])[0])\n",
    "    t_range.append(time)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[OK] b'fmi2Terminate'\n",
      "fmi2Terminate(component=0x1869a823ae0) -> OK\n",
      "[OK] b'fmi2FreeInstance'\n",
      "fmi2FreeInstance(component=0x1869a823ae0)\n"
     ]
    }
   ],
   "source": [
    "# Terminate FMU and cleanup\n",
    "msd1.fmu.terminate()\n",
    "FMULoader.unload(msd1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 9440 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(1)\n",
    "plt.plot(t_range,xs, 'o', markersize=3, label='x1')\n",
    "plt.xlabel('t (s)')\n",
    "plt.ylabel('position (m)')\n",
    "\n",
    "plt.legend()\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exercise 1: Give input to Mass Spring Damper System"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Repeat the above steps, but this time, at each co-simulation step, define the value of `fk` so that `fk(t)=sin(t)`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Import sin function\n",
    "import math\n",
    "\n",
    "# TODO Load msd1\n",
    "\n",
    "# TODO Instantiate FMU\n",
    "\n",
    "# TODO Setup experiment\n",
    "\n",
    "# TODO Enter Initialization Mode\n",
    "\n",
    "# TODO Set Parameters and Initial Values\n",
    "\n",
    "# TODO Exit Initialization Mode\n",
    "\n",
    "\n",
    "# Define timestep \n",
    "H = 0.01\n",
    "\n",
    "# Will store current cosim time\n",
    "time = 0.0\n",
    "\n",
    "# Will store the timepoints\n",
    "t_range = [time]\n",
    "\n",
    "# Will store current position of the mass\n",
    "xs = [msd1.fmu.getReal([msd1.vars['x1'].valueReference])[0]]\n",
    "\n",
    "# Run cosim steps\n",
    "while (time+H)<=stop_time:\n",
    "    msd1.fmu.doStep(time, H)\n",
    "    # TODO Set input to the fmu\n",
    "    \n",
    "    # Advance time\n",
    "    time = time + H\n",
    "    xs.append(msd1.fmu.getReal([msd1.vars['x1'].valueReference])[0])\n",
    "    t_range.append(time)\n",
    "\n",
    "# Terminate FMU and cleanup\n",
    "msd1.fmu.terminate()\n",
    "FMULoader.unload(msd1)\n",
    "\n",
    "# Plot\n",
    "plt.figure(1)\n",
    "plt.plot(t_range, xs, 'o', markersize=3, label='x1')\n",
    "plt.xlabel('t (s)')\n",
    "plt.ylabel('position (m)')\n",
    "\n",
    "plt.legend()\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exercise 2: Create your Own (Virtual) FMU\n",
    "\n",
    "Create your own FMU of the mass spring damper system."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from cosimlibrary.virtual_fmus import VirtualFMU\n",
    "from fmpy.fmi2 import fmi2True\n",
    "\n",
    "class MSD1(VirtualFMU):\n",
    "    def __init__(self, instanceName):\n",
    "        # Declare value references for variables\n",
    "        ref = 0\n",
    "        self.x1 = ref;\n",
    "        ref += 1\n",
    "        self.v1 = ref;\n",
    "        ref += 1\n",
    "        self.m1 = ref;\n",
    "        ref += 1\n",
    "        self.c1 = ref;\n",
    "        ref += 1\n",
    "        self.d1 = ref;\n",
    "        ref += 1\n",
    "        self.fk = ref;\n",
    "        ref += 1\n",
    "        super().__init__(instanceName, ref)\n",
    "\n",
    "    def doStep(self, currentCommunicationPoint, communicationStepSize, noSetFMUStatePriorToCurrentPoint=fmi2True):\n",
    "        h = 1e-3 # Internal step size\n",
    "        t = currentCommunicationPoint\n",
    "        maxT = t + communicationStepSize # Time to terminate the doStep\n",
    "        while (t < maxT):\n",
    "            if t+h > maxT:\n",
    "                h = (maxT - t) # Make sure we leave the co-sim step at time maxT\n",
    "            \n",
    "            # Compute derivative of v\n",
    "            der_v = (1.0 / self.state[self.m1]) * (- self.state[self.c1] * self.state[self.x1]\n",
    "                                                  - self.state[self.d1] * self.state[self.v1]\n",
    "                                                  + self.state[self.fk])\n",
    "            \n",
    "            # TODO Compute derivative of x\n",
    "            der_x = ...\n",
    "            \n",
    "            # TODO: Implement forward euler\n",
    "            self.state[self.x1] = ...\n",
    "            self.state[self.v1] = ...\n",
    "            \n",
    "            # Advance time\n",
    "            t=t+h\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exercise 3: Run Co-simulations with Varying Step Sizes\n",
    "\n",
    "Define a function that runs a co-simulation with the previous virtual FMU, for a given communication step size.\n",
    "Then run multiple co-simulations with varying communication step sizes, and explain the results: \n",
    "- Why do the results differ despite the fact that the solver used is the same (and has the same step size)?\n",
    "\n",
    "In each co-simulation, the mass should start at a resting state ($x_1(0) = v_1(0) = 0$), and at each co-simulation step at time $t$, the value of `fk` should be `fk(t)=sin(t)`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Import sin function\n",
    "import math\n",
    "\n",
    "def run_virtual_cosim(H):\n",
    "    # Load msd1. No need to use Loader, as this is a virtual FMU.\n",
    "    msd1fmu = MSD1('msd1')\n",
    "\n",
    "    # Instantiate FMU\n",
    "    msd1fmu.instantiate(loggingOn=False) \n",
    "\n",
    "    # TODO Setup experiment\n",
    "\n",
    "    # TODO Enter Initialization Mode\n",
    "\n",
    "    # TODO Set Parameters and Initial Values\n",
    "    # Example: msd1fmu.setReal([msd1fmu.fk], [0.0])\n",
    "\n",
    "    # TODO Exit Initialization Mode\n",
    "\n",
    "    # Will store current cosim time\n",
    "    time = 0.0\n",
    "\n",
    "    # Will store the timepoints\n",
    "    t_range = [time]\n",
    "\n",
    "    # Will store current position of the mass\n",
    "    xs = [msd1fmu.getReal([msd1fmu.x1])[0]]\n",
    "\n",
    "    # Run cosim steps\n",
    "    while (time+H)<=stop_time:\n",
    "        # Do Step\n",
    "        msd1fmu.doStep(time, H)\n",
    "        # TODO Set input\n",
    "        \n",
    "        # Advance time\n",
    "        time = time + H\n",
    "        # Record outputs\n",
    "        xs.append(msd1fmu.getReal([msd1fmu.x1])[0])\n",
    "        t_range.append(time)\n",
    "\n",
    "    # Terminate FMU and cleanup\n",
    "    msd1fmu.terminate()\n",
    "    \n",
    "    return t_range, xs\n",
    "\n",
    "# Run cosims\n",
    "t0001, xs0001 = run_virtual_cosim(0.001)\n",
    "t001, xs001 = run_virtual_cosim(0.01)\n",
    "t01, xs01 = run_virtual_cosim(0.1)\n",
    "t05, xs05 = run_virtual_cosim(0.5)\n",
    "\n",
    "# Plot\n",
    "plt.figure(1)\n",
    "plt.plot(t0001, xs0001, 'o', markersize=3, label='xs0001')\n",
    "plt.plot(t001, xs001, 'o', markersize=3, label='xs001')\n",
    "plt.plot(t01, xs01, 'o', markersize=3, label='xs01')\n",
    "plt.plot(t05, xs05, 'o', markersize=3, label='xs05')\n",
    "plt.xlabel('t (s)')\n",
    "plt.ylabel('position (m)')\n",
    "\n",
    "plt.legend()\n",
    "\n",
    "plt.show()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
