BELFEM 0.9.0
Berkeley Lab Finite Element Framework
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
22namespace belfem
23{
24 class SourceFunction;
25
26 namespace electronics
27 {
28//-----------------------------------------------------------------------------
29
31
32//-----------------------------------------------------------------------------
33
76 {
77 const string mSource; // for error messages
78
83 std::unique_ptr< ElectricalCircuit > mCircuit;
84
87 uint mNumberOfNodes = 0;
88
89//-----------------------------------------------------------------------------
90 public:
91//-----------------------------------------------------------------------------
92
96 NgspiceCircuitFactory( const NetlistParser & aNetlist );
97
101 NgspiceCircuitFactory( const string & aPath );
102
104
105//-----------------------------------------------------------------------------
106
112 circuit();
113
120 index_t
121 node_index( const string & aName ) const;
122
123 uint
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
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
Definition cl_SourceFunction.hpp:80
The circuit itself: MNA assembly, Jacobian, solve and timestep.
Definition cl_ElectricalCircuit.hpp:39
Lexes an ngspice netlist into the intermediate representation the NgspiceCircuitFactory consumes ( to...
Definition cl_NetlistParser.hpp:144
uint number_of_nodes() const
Definition cl_NgspiceCircuitFactory.hpp:124
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
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
NgspiceCircuitFactory(const NetlistParser &aNetlist)
build from a lexed netlist
Definition cl_NgspiceCircuitFactory.cpp:32
Definition cl_Capacitor.cpp:18
USER GUIDES:
Definition cl_Capacitor.cpp:16
unsigned int uint
Definition typedefs.hpp:30
uint32_t index_t
Definition typedefs.hpp:52
double real
Definition typedefs.hpp:36
one "* belfem:" extension directive ( plan §5, Option A ): superconductor, timed switch,...
Definition cl_NetlistParser.hpp:92
one element card ( R/C/L/V/I/D ), lexed but not interpreted: all payloads stay strings; numeric conve...
Definition cl_NetlistParser.hpp:31