![]() |
WarpTwin
Documentation for WarpTwin models and classes.
|
/******************************************************************************
* Copyright (c) ATTX INC 2025. All Rights Reserved.
*
* This software and associated documentation (the "Software") are the
* proprietary and confidential information of ATTX INC. The Software is
* furnished under a license agreement between ATTX and the user organization
* and may be used or copied only in accordance with the terms of the agreement.
* Refer to 'license/attx_license.adoc' for standard license terms.
*
* EXPORT CONTROL NOTICE: THIS SOFTWARE MAY INCLUDE CONTENT CONTROLLED UNDER THE
* INTERNATIONAL TRAFFIC IN ARMS REGULATIONS (ITAR) OR THE EXPORT ADMINISTRATION
* REGULATIONS (EAR99). No part of the Software may be used, reproduced, or
* transmitted in any form or by any means, for any purpose, without the express
* written permission of ATTX INC.
******************************************************************************/
/*
Simple power system header file
Author: Alex Reynolds
*/
/*
Metadata for MS GUI:
imdata = {"displayname" : "Simple Battery System",
"exclude" : False,
"category" : "Power"
}
aliases = {"peak_battery_voltage" : "Peak Voltage/Battery",
"single_battery_capacity" : "Capacity/Battery (W*hr)",
"shutoff_capacity" : "Shutoff Capacity",
"initial_charge_state" : "Initial Charge",
"num_batteries_series" : "Num Batteries/String",
"num_batteries_parallel" : "Num Strings",
"power_generation_in" : "Power In",
"power_draw_out" : "Power Out",
"net_power_change" : "EXCLUDE",
"system_voltage" : "Battery Voltage",
"current_draw" : "Battery Current",
"power_available" : "Power Available"
}
*/
#ifndef MODELS_POWER_SIMPLE_POWER_SYSTEM_H
#define MODELS_POWER_SIMPLE_POWER_SYSTEM_H
#include "simulation/Model.h"
#include "utils/Interpolate2D.h"
#include "locations.h"
namespace warptwin {
/**
* @brief Simplified model of vehicle battery system which estimates battery capacity considering power input, draw
*
* Author: Alex Reynolds <alex@attx.tech>
*/
MODEL(SimpleBatterySystem)
public:
// Model params
// NAME TYPE DEFAULT VALUE
START_PARAMS
/** The peak voltage provided by a single battery (summed to make full pack) */
SIGNAL(peak_battery_voltage, double, 0.0)
/** The capacity, in W*hr, provided by a single spacecraft battery */
SIGNAL(single_battery_capacity, double, 0.0)
/** The % of charge at which power shuts off. Default is 0.0 (no shutoff until capacity is empty) */
SIGNAL(shutoff_capacity, double, 0.0)
/** Should be a percent. value in the range 0-->1 indicating the initial charge state of the system */
SIGNAL(initial_charge_state, double, 1.0)
/** The number of batteries configured in series. Determines the system voltage and shutoff */
SIGNAL(num_batteries_series, int, 1)
/** The number of batteries configured in parallel. Used with series to determine system capacity */
SIGNAL(num_batteries_parallel, int, 1)
/** The capacity-voltage curve defined by percent capacity against pct max voltage. Default is lithium ion */
SIGNAL(capacity_voltage_def, std::string, warptwinDir()+"data"+slash()+"power"+slash()+"lithium_ion.json")
END_PARAMS
// Model inputs
// NAME TYPE DEFAULT VALUE
START_INPUTS
/** The amount of power generated by the system in the given step, in W */
SIGNAL(power_generation_in, double, 0.0)
/** The amount of power drawn from the system in the given step, in W */
SIGNAL(power_draw_out, double, 0.0)
END_INPUTS
// Model outputs
// NAME TYPE DEFAULT VALUE
START_OUTPUTS
/** The net change in power in the system for the step, in W */
SIGNAL(net_power_change, double, 0.0)
/** The depth of discharge, a percentage value denoting the depletion of the battery system. (%) */
SIGNAL(depth_of_discharge, double, 0.0)
/** The current voltage of the power system */
SIGNAL(system_voltage, double, 0.0)
/** The current draw of the system, in Amps */
SIGNAL(current_draw, double, 0.0)
/** Boolean indicating whether power is available (true) or not (false) from the system */
SIGNAL(power_available, int, 0)
END_OUTPUTS
protected:
int16 start() override;
int16 execute() override;
double _total_system_capacity; // The total capacity of the system in W*s
double _peak_system_voltage; // Voltage when the system is at full capacity
double _system_shutoff_capacity;// Capacity at which the system will shut off
double _current_capacity; // The current capacity of the system in W*s
Interpolate2D _voltage_interp_table;
};
}
#endif