SEElectricalCompartment.h
1/* Distributed under the Apache License, Version 2.0.
2 See accompanying NOTICE file for details.*/
3#pragma once
4#include "cdm/blackbox/SEBlackBox.h"
5#include "cdm/compartment/SECompartment.h"
6#include "cdm/compartment/SECompartmentNodes.h"
7#include "cdm/circuit/electrical/SEElectricalCircuitNode.h"
10
12{
13 friend class PBCompartment;//friend the serialization class
15 template<typename CompartmentType, typename CompartmentLinkType> friend class SECompartmentGraph;
16protected:
17 SEElectricalCompartment(const std::string& name, Logger* logger);
18public:
20
21 void Clear() override;
22
23 const SEScalar* GetScalar(const std::string& name) override;
24
25 virtual bool HasChildren() const override { return !m_Children.empty(); }
26 virtual const std::vector<SEElectricalCompartment*>& GetChildren() { return m_Children; }
27 virtual const std::vector<SEElectricalCompartment*>& GetLeaves() { return m_Leaves; }
28
29 virtual bool HasNodeMapping() const { return m_Nodes.HasMapping(); }
31 virtual void MapNode(SEElectricalCircuitNode& node);
32
33 void StateChange() override;
34
35 virtual bool HasCurrentIn() const;
36 virtual const SEScalarElectricCurrent& GetCurrentIn() const;
37 virtual double GetCurrentIn(const ElectricCurrentUnit& unit) const;
38
39 virtual bool HasCurrentOut() const;
40 virtual const SEScalarElectricCurrent& GetCurrentOut() const;
41 virtual double GetCurrentOut(const ElectricCurrentUnit& unit) const;
42
43 virtual bool HasCharge() const;
44 virtual SEScalarElectricCharge& GetCharge();
45 virtual double GetCharge(const ElectricChargeUnit& unit) const;
46
47 virtual bool HasVoltage() const;
48 virtual SEScalarElectricPotential& GetVoltage();
49 virtual double GetVoltage(const ElectricPotentialUnit& unit) const;
50
51 virtual void AddLink(SEElectricalCompartmentLink& link);
52 virtual void RemoveLink(SEElectricalCompartmentLink& link);
53 virtual void RemoveLinks();
54 virtual const std::vector<SEElectricalCompartmentLink*>& GetLinks();
55
56 virtual bool HasChild(const SEElectricalCompartment& cmpt);
57 virtual void AddChild(SEElectricalCompartment& child);
58
59protected:
60 virtual double CalculateInFlow_A() const;
61 virtual double CalculateOutFlow_A() const;
62
67
68 std::vector<SEElectricalCompartmentLink*> m_Links;
69 std::vector<SEElectricalCompartmentLink*> m_IncomingLinks;
70 std::vector<SEElectricalCompartmentLink*> m_OutgoingLinks;
71
72 std::vector<SEElectricalCompartment*> m_Children;
73 std::vector<SEElectricalCompartment*> m_Leaves;
75};
Definition: SEScalarElectricCharge.h:8
Definition: SEScalarElectricCurrent.h:8
Definition: SEScalarElectricPotential.h:8
Definition: Logger.h:71
Definition: PBCompartment.h:28
Definition: SECompartmentGraph.h:11
virtual void RemoveLink(const CompartmentLinkType &link)
virtual const std::vector< CompartmentLinkType * > & GetLinks() const
virtual void AddLink(CompartmentLinkType &link)
Definition: SECompartment.h:14
virtual void Clear()
Definition: SECompartment.cpp:18
virtual const SEScalar * GetScalar(const std::string &name)=0
virtual void StateChange()=0
Definition: SECompartmentManager.h:25
Definition: SEElectricalCircuitNode.h:10
Definition: SEElectricalCompartment.h:12
virtual const std::vector< SEElectricalCompartment * > & GetChildren()
Definition: SEElectricalCompartment.h:26
SEScalarElectricPotential * m_Voltage
Definition: SEElectricalCompartment.h:66
std::vector< SEElectricalCompartmentLink * > m_Links
Definition: SEElectricalCompartment.h:68
SECompartmentNodes< ELECTRICAL_COMPARTMENT_NODE > m_Nodes
Definition: SEElectricalCompartment.h:74
std::vector< SEElectricalCompartment * > m_Children
Definition: SEElectricalCompartment.h:72
SEScalarElectricCurrent * m_CurrentOut
Definition: SEElectricalCompartment.h:64
virtual SECompartmentNodes< ELECTRICAL_COMPARTMENT_NODE > & GetNodeMapping()
Definition: SEElectricalCompartment.h:30
virtual bool HasChildren() const override
Definition: SEElectricalCompartment.h:25
std::vector< SEElectricalCompartmentLink * > m_IncomingLinks
Definition: SEElectricalCompartment.h:69
SEScalarElectricCharge * m_Charge
Definition: SEElectricalCompartment.h:65
std::vector< SEElectricalCompartmentLink * > m_OutgoingLinks
Definition: SEElectricalCompartment.h:70
virtual const std::vector< SEElectricalCompartment * > & GetLeaves()
Definition: SEElectricalCompartment.h:27
SEScalarElectricCurrent * m_CurrentIn
Definition: SEElectricalCompartment.h:63
std::vector< SEElectricalCompartment * > m_Leaves
Definition: SEElectricalCompartment.h:73
virtual bool HasNodeMapping() const
Definition: SEElectricalCompartment.h:29
Definition: SEScalarElectricCharge.h:24
Definition: SEScalarElectricCurrent.h:24
Definition: SEScalarElectricPotential.h:25
Definition: SEScalar.h:19

Distributed under the Apache License, Version 2.0.

See accompanying NOTICE file for details.