BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
belfem::electronics Namespace Reference

Classes

class  Capacitor
class  Component
 Base class for every circuit component. More...
class  CurrentSource
class  Diode
class  ElectricalCircuit
 The circuit itself: MNA assembly, Jacobian, solve and timestep. More...
class  ElectricalCircuitFactory
 Builds the circuit from the input deck's circuit{} section. More...
class  ElectricNode
 Circuit node; the unknowns of the modified nodal analysis. More...
class  FEMTwoTerminals
 Terminal pair coupling the circuit to the finite-element problem. More...
class  Inductor
struct  NetlistControl
 one supported control card ( only ".tran" today; ".end" sets a flag instead of a record ) More...
struct  NetlistDirective
 one "* belfem:" extension directive ( plan §5, Option A ): superconductor, timed switch, per-instance BDF order More...
struct  NetlistElement
 one element card ( R/C/L/V/I/D ), lexed but not interpreted: all payloads stay strings; numeric conversion and semantic validation are the netlist factory's job More...
struct  NetlistModel
 one .model card ( ".model dmod d( is=1e-14 )" ) More...
class  NetlistParser
 Lexes an ngspice netlist into the intermediate representation the NgspiceCircuitFactory consumes ( todo/ngspice_parser_plan.md §9.1 ). More...
class  NgspiceCircuitFactory
 Builds an ElectricalCircuit from a lexed netlist ( todo/ngspice_parser_plan.md §9.2, decisions O5/O6/O8/O9 ). More...
class  Resistor
class  Superconductor
class  Switch
class  TwoTerminals
class  VoltageSource

Enumerations

enum class  ComponentType {
  RESISTOR = 0 , CAPACITOR = 1 , INDUCTOR = 2 , VOLTAGESOURCE = 3 ,
  CURRENTSOURCE = 4 , SWITCH = 5 , DIODE = 6 , SUPERCONDUCTOR = 7 ,
  TERMINALPAIR = 8 , UNDEFINED = 9
}

Functions

std::string to_string (const ComponentType aComponentType)
ComponentType component_type (const string &aString)
void save_shift_register (hid_t &aGroup, const string &aLabel, const ShiftRegister< real > &aRegister)
 write one time-stepping history register into the restart group, as aLabel ( samples, newest first ) and aLabel_cap ( capacity )
void load_shift_register (hid_t &aGroup, const string &aLabel, ShiftRegister< real > &aRegister)
 restore one history register saved by save_shift_register().
real spice_number_to_si (const string &aToken)
 Convert one SPICE number token into its SI value.

Enumeration Type Documentation

◆ ComponentType

Enumerator
RESISTOR 
CAPACITOR 
INDUCTOR 
VOLTAGESOURCE 
CURRENTSOURCE 
SWITCH 
DIODE 
SUPERCONDUCTOR 
TERMINALPAIR 
UNDEFINED 

Function Documentation

◆ component_type()

ComponentType belfem::electronics::component_type ( const string & aString)

◆ load_shift_register()

void belfem::electronics::load_shift_register ( hid_t & aGroup,
const string & aLabel,
ShiftRegister< real > & aRegister )
inline

restore one history register saved by save_shift_register().

The rebuild is clear() + oldest-first push(): the visible window is identical to the dumped one. The revert flag after a FULL rebuild is CanRevert rather than the live CanRevertFull ( the backup slot is not refilled ) — calling shift_back() before the first post-restore shift() is therefore FORBIDDEN; every production reject path shifts first.

◆ save_shift_register()

void belfem::electronics::save_shift_register ( hid_t & aGroup,
const string & aLabel,
const ShiftRegister< real > & aRegister )
inline

write one time-stepping history register into the restart group, as aLabel ( samples, newest first ) and aLabel_cap ( capacity )

◆ spice_number_to_si()

real belfem::electronics::spice_number_to_si ( const string & aToken)

Convert one SPICE number token into its SI value.

Implements the ngspice number grammar (ngspice manual, "Ngspice scale factors" table and the "Letters following a number" rule): an integer (12, -44), a floating point number (3.14159), either followed by an integer exponent (1e-14, 2.65e3), optionally followed by a case-insensitive scale factor

T = 1e12 G = 1e9 Meg = 1e6 K = 1e3 mil = 25.4e-6 m = 1e-3 u = 1e-6 n = 1e-9 p = 1e-12 f = 1e-15 a = 1e-18

with longest match first (Meg and mil win over m). Letters immediately after the number or the scale factor are ignored, so 10, 10V, 10Volts and 10Hz are the same number and 1k, 1kOhm and 1kHz the same value. SPICE values are dimensionless SI: F is the femto scale factor, never Farad – a 100 F capacitor is written "100", while "100F" is 100 fF. The same trap exists for currents: A is the atto scale factor, never Ampere – a 1 A source is written "1", while "1A" is 1e-18.

Errors (BELFEM_ERROR): empty token, no leading number ("abc", "inf", "0x10"), a magnitude outside [DBL_MIN, DBL_MAX] other than exact zero, before or after the scale factor is applied ("1e999", "1e-999", "1e300T", and subnormals like "1e-320"), or any non-letter character after the number/scale factor – including the old-style embedded suffix "2k5" (write "2.5k") and embedded whitespace. Conversion is locale-independent (std::from_chars).

Parameters
aTokenone whitespace-free token from a netlist card
Returns
the value in SI units

◆ to_string()

string belfem::electronics::to_string ( const ComponentType aComponentType)