85 lines
2.8 KiB
C++
85 lines
2.8 KiB
C++
#ifndef CIRCUIT_HPP
|
|
#define CIRCUIT_HPP
|
|
#include <vector>
|
|
#include <iostream>
|
|
#include "devices.hpp"
|
|
class Circuit
|
|
{
|
|
public:
|
|
int numNodes;
|
|
std::vector<Resistor> resistors;
|
|
std::vector<Capacitor> capacitors;
|
|
std::vector<Inductor> inductors;
|
|
std::vector<VoltageSource> voltageSources;
|
|
std::vector<CurrentSource> currentSources;
|
|
std::vector<VCCS> vccs;
|
|
std::vector<VCVS> vcvs;
|
|
std::vector<CCCS> cccs;
|
|
std::vector<CCVS> ccvs;
|
|
std::vector<Diode> diodes;
|
|
std::vector<Mosfet> mosfets;
|
|
std::vector<VCR> vcrs;
|
|
|
|
Circuit() = default;
|
|
|
|
Circuit(int n) : numNodes(n) {}
|
|
|
|
void addResistor(int node1, int node2, double resistance)
|
|
{
|
|
resistors.emplace_back(node1, node2, resistance);
|
|
}
|
|
|
|
void addCapacitor(int node1, int node2, double capacitance)
|
|
{
|
|
capacitors.emplace_back(node1, node2, capacitance, 0.0, 0.0);
|
|
}
|
|
|
|
void addInductor(int node1, int node2, double inductance)
|
|
{
|
|
inductors.emplace_back(node1, node2, inductance, 0.0, 0.0);
|
|
}
|
|
|
|
void addCurrentSource(int node1, int node2, double current)
|
|
{
|
|
currentSources.emplace_back(node1, node2, current);
|
|
}
|
|
|
|
void addVoltageSource(int node1, int node2, double voltage, std::string type = "DC")
|
|
{
|
|
voltageSources.emplace_back(node1, node2, voltage, type);
|
|
}
|
|
|
|
void addVCCS(int outputNodePos, int outputNodeNeg, int controlNodePos, int controlNodeNeg, double gm)
|
|
{
|
|
vccs.emplace_back(controlNodePos, controlNodeNeg, outputNodePos, outputNodeNeg, gm);
|
|
}
|
|
|
|
void addVCR(int outputNodePos, int outputNodeNeg, int controlNodePos, int controlNodeNeg, double gain,std::string type)
|
|
{
|
|
vcrs.emplace_back(controlNodePos, controlNodeNeg, outputNodePos, outputNodeNeg, gain,type);
|
|
}
|
|
|
|
void addVCVS(int outputNodePos, int outputNodeNeg, int controlNodePos, int controlNodeNeg, double gain)
|
|
{
|
|
vcvs.emplace_back(controlNodePos, controlNodeNeg, outputNodePos, outputNodeNeg, gain);
|
|
}
|
|
void addCCCS(int outputNodePos, int outputNodeNeg, int controlNodePos, int controlNodeNeg, double voltage, double gain)
|
|
{
|
|
cccs.emplace_back(controlNodePos, controlNodeNeg, outputNodePos, outputNodeNeg, gain, voltage);
|
|
}
|
|
|
|
void addCCVS(int outputNodePos, int outputNodeNeg, int controlNodePos, int controlNodeNeg, double voltage, double gain)
|
|
{
|
|
ccvs.emplace_back(controlNodePos, controlNodeNeg, outputNodePos, outputNodeNeg, gain, voltage);
|
|
}
|
|
void addDiode(int nodeP, int nodeN, double Is, double n)
|
|
{
|
|
diodes.emplace_back(nodeP, nodeN, Is, n);
|
|
}
|
|
void addMosfet(int gate, int source, int drain, double Vth, double K, MosType type)
|
|
{
|
|
mosfets.emplace_back(gate, source, drain, Vth, K, type);
|
|
}
|
|
};
|
|
|
|
#endif |