BELFEM
0.9.0
Berkeley Lab Finite Element Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
cl_NgspiceCircuitFactory.hpp
Go to the documentation of this file.
1
/*
2
* BELFEM -- The Berkeley Lab Finite Element Framework
3
* Copyright (c) 2026, The Regents of the University of California,
4
* through Lawrence Berkeley National Laboratory (subject to receipt of any required
5
* approvals from the U.S. Dept. of Energy). All rights reserved.
6
*
7
* Developers: Christian Messe, Gregory Giard
8
*
9
* See the top-level LICENSE file for the complete license and disclaimer.
10
*/
11
12
#ifndef BELFEM_CL_NGSPICECIRCUITFACTORY_HPP
13
#define BELFEM_CL_NGSPICECIRCUITFACTORY_HPP
14
15
#include <memory>
16
17
#include "
typedefs.hpp
"
18
#include "
cl_Cell.hpp
"
19
#include "
cl_Map.hpp
"
20
#include "
cl_NetlistParser.hpp
"
21
22
namespace
belfem
23
{
24
class
SourceFunction
;
25
26
namespace
electronics
27
{
28
//-----------------------------------------------------------------------------
29
30
class
ElectricalCircuit
;
31
32
//-----------------------------------------------------------------------------
33
75
class
NgspiceCircuitFactory
76
{
77
const
string
mSource;
// for error messages
78
83
std::unique_ptr< ElectricalCircuit > mCircuit;
84
86
Map< string, index_t >
mNodeMap;
87
uint
mNumberOfNodes = 0;
88
89
//-----------------------------------------------------------------------------
90
public
:
91
//-----------------------------------------------------------------------------
92
96
NgspiceCircuitFactory
(
const
NetlistParser
& aNetlist );
97
101
NgspiceCircuitFactory
(
const
string
& aPath );
102
103
~NgspiceCircuitFactory
();
104
105
//-----------------------------------------------------------------------------
106
111
ElectricalCircuit
*
112
circuit
();
113
120
index_t
121
node_index
(
const
string
& aName )
const
;
122
123
uint
124
number_of_nodes
()
const
125
{
126
return
mNumberOfNodes;
127
}
128
129
//-----------------------------------------------------------------------------
130
private
:
131
//-----------------------------------------------------------------------------
132
133
void
134
build(
const
NetlistParser
& aNetlist );
135
136
void
137
build_node_map(
const
NetlistParser
& aNetlist );
138
140
void
141
collect_orders(
const
NetlistParser
& aNetlist,
142
Map< string, uint >
& aOrders )
const
;
143
144
void
145
create_element(
const
NetlistElement
& aElement,
146
const
NetlistParser
& aNetlist,
147
const
Map< string, uint >
& aOrders );
148
149
void
150
create_from_directive(
const
NetlistDirective
& aDirective );
151
153
real
154
rcl_value(
const
NetlistElement
& aElement,
155
const
char
* aKeyword )
const
;
156
159
SourceFunction
*
160
source_function(
const
NetlistElement
& aElement )
const
;
161
162
index_t
163
node_index_checked(
const
string
& aName,
164
const
string
& aCard,
165
const
index_t
aLine )
const
;
166
168
static
bool
169
is_ground(
const
string
& aName );
170
171
//-----------------------------------------------------------------------------
172
};
173
174
//-----------------------------------------------------------------------------
175
}
176
}
177
178
#endif
//BELFEM_CL_NGSPICECIRCUITFACTORY_HPP
cl_Cell.hpp
cl_Map.hpp
cl_NetlistParser.hpp
belfem::Map< string, index_t >
belfem::SourceFunction
Definition
cl_SourceFunction.hpp:80
belfem::electronics::ElectricalCircuit
The circuit itself: MNA assembly, Jacobian, solve and timestep.
Definition
cl_ElectricalCircuit.hpp:39
belfem::electronics::NetlistParser
Lexes an ngspice netlist into the intermediate representation the NgspiceCircuitFactory consumes ( to...
Definition
cl_NetlistParser.hpp:144
belfem::electronics::NgspiceCircuitFactory::~NgspiceCircuitFactory
~NgspiceCircuitFactory()
belfem::electronics::NgspiceCircuitFactory::number_of_nodes
uint number_of_nodes() const
Definition
cl_NgspiceCircuitFactory.hpp:124
belfem::electronics::NgspiceCircuitFactory::circuit
ElectricalCircuit * circuit()
hand the circuit over to the caller, who owns it from here; hard-errors on a second call
Definition
cl_NgspiceCircuitFactory.cpp:56
belfem::electronics::NgspiceCircuitFactory::node_index
index_t node_index(const string &aName) const
resolve a netlist node name ( case-folded; ground aliases "0"/"gnd" allowed ) to its BELFEM index – t...
Definition
cl_NgspiceCircuitFactory.cpp:200
belfem::electronics::NgspiceCircuitFactory::NgspiceCircuitFactory
NgspiceCircuitFactory(const NetlistParser &aNetlist)
build from a lexed netlist
Definition
cl_NgspiceCircuitFactory.cpp:32
belfem::electronics
Definition
cl_Capacitor.cpp:18
belfem
USER GUIDES:
Definition
cl_Capacitor.cpp:16
belfem::uint
unsigned int uint
Definition
typedefs.hpp:30
belfem::index_t
uint32_t index_t
Definition
typedefs.hpp:52
belfem::real
double real
Definition
typedefs.hpp:36
belfem::electronics::NetlistDirective
one "* belfem:" extension directive ( plan §5, Option A ): superconductor, timed switch,...
Definition
cl_NetlistParser.hpp:92
belfem::electronics::NetlistElement
one element card ( R/C/L/V/I/D ), lexed but not interpreted: all payloads stay strings; numeric conve...
Definition
cl_NetlistParser.hpp:31
typedefs.hpp
src
circuit
cl_NgspiceCircuitFactory.hpp
Generated by
1.18.0