BELFEM 0.9.3
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
75 {
76 const string mSource; // for error messages
77
82 std::unique_ptr< ElectricalCircuit > mCircuit;
83
86 uint mNumberOfNodes = 0;
87
88//-----------------------------------------------------------------------------
89 public:
90//-----------------------------------------------------------------------------
91
95 NgspiceCircuitFactory( const NetlistParser & aNetlist );
96
100 NgspiceCircuitFactory( const string & aPath );
101
103
104//-----------------------------------------------------------------------------
105
111 circuit();
112
119 index_t
120 node_index( const string & aName ) const;
121
122 uint
124 {
125 return mNumberOfNodes;
126 }
127
128//-----------------------------------------------------------------------------
129 private:
130//-----------------------------------------------------------------------------
131
132 void
133 build( const NetlistParser & aNetlist );
134
135 void
136 build_node_map( const NetlistParser & aNetlist );
137
139 void
140 collect_orders( const NetlistParser & aNetlist,
141 Map< string, uint > & aOrders ) const;
142
143 void
144 create_element( const NetlistElement & aElement,
145 const NetlistParser & aNetlist,
146 const Map< string, uint > & aOrders );
147
148 void
149 create_from_directive( const NetlistDirective & aDirective );
150
152 real
153 rcl_value( const NetlistElement & aElement,
154 const char * aKeyword ) const;
155
159 source_function( const NetlistElement & aElement ) const;
160
161 index_t
162 node_index_checked( const string & aName,
163 const string & aCard,
164 const index_t aLine ) const;
165
167 static bool
168 is_ground( const string & aName );
169
170//-----------------------------------------------------------------------------
171 };
172
173//-----------------------------------------------------------------------------
174 }
175}
176
177#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.
Definition cl_NetlistParser.hpp:144
uint number_of_nodes() const
Definition cl_NgspiceCircuitFactory.hpp:123
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