From e6060e8b97bbd7f27fe8d38a883a898b48007406 Mon Sep 17 00:00:00 2001 From: Michael Hayes Date: Mon, 6 Nov 2023 22:08:43 +1300 Subject: [PATCH] Use omega0 as default angular frequency for ac #115 --- lcapy/netlist.py | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/lcapy/netlist.py b/lcapy/netlist.py index b812b0c4..798eb644 100644 --- a/lcapy/netlist.py +++ b/lcapy/netlist.py @@ -24,7 +24,7 @@ from .subnetlist import SubNetlist from .superpositionvoltage import SuperpositionVoltage from .superpositioncurrent import SuperpositionCurrent -from .symbols import j, s, t, omega +from .symbols import j, s, t, omega, omega0 from .transformdomains import TransformDomains from .utils import isiterable from copy import copy @@ -331,14 +331,19 @@ def get_vd(self, Np, Nm=None): return self.get_Vd(Np, Nm).time() - def ac(self): + def ac(self, omega=None): """Return netlist for ac components of independent sources - for angular frequency omega. + for angular frequency `omega`. If `omega` is undefined, + the angular frequency `omega0` is used. See also: dc, transient, laplace. """ - # Could look at all the ac frequencies and if there is only - # one use that? If have multiple ac frequencies should issue + + if omega is None: + omega = omega0 + + # Should look at all the ac frequencies and if there is only + # one use that. If have multiple ac frequencies should issue # warning. return self.select(omega) @@ -354,15 +359,15 @@ def annotate_currents(self, cpts=None, domainvar=None, flow=False, `flow` (default False) if True annotates current as a flow `eng_format` (default True) if True use engineering format if - the current is a number, e.g., 100\,mV instead of 0.1\,V + the current is a number, e.g., 100\, mV instead of 0.1\, V `evalf` (default True) if True prints floating point numbers as decimals otherwise they are shown as rationals - `show_units` (default True) if True applies the units (e.g., + `show_units` (default True) if True applies the units(e.g., V for volts) - `pos` specifies where to position the labels (see docs) + `pos` specifies where to position the labels(see docs) """ cct = self.copy() @@ -405,15 +410,15 @@ def annotate_voltages(self, cpts=None, domainvar=None, `pos` specifies where to position the labels, see docs `eng_format` (default True) if True use engineering format if - the voltage is a number, e.g., 100\,mV instead of 0.1\,V + the voltage is a number, e.g., 100\, mV instead of 0.1\, V `evalf` (default True) if True prints floating point numbers as decimals otherwise they are shown as rationals - `show_units` (default True) if True applies the units (e.g., + `show_units` (default True) if True applies the units(e.g., V for volts) - `pos` specifies where to position the labels (see docs) + `pos` specifies where to position the labels(see docs) """ cct = self.copy() @@ -459,10 +464,10 @@ def annotate_node_voltages(self, nodes=None, domainvar=None, (e.g., `t` for time-domain, `s` for Laplace-domain) `label_voltages` (default False) if True prefixes the - annotation with V1= for node 1, etc. + annotation with V1 = for node 1, etc. `eng_format` (default True) if True use engineering format if - the voltage is a number, e.g., 100\,mV instead of 0.1\,V + the voltage is a number, e.g., 100\, mV instead of 0.1\, V `evalf` (default True) if True prints floating point numbers as decimals otherwise they are shown as rationals @@ -470,7 +475,7 @@ def annotate_node_voltages(self, nodes=None, domainvar=None, `num_digits` (default 3) specfies the number of digits to print for floating point numbers - `show_units` (default True) if True applies the units (e.g., + `show_units` (default True) if True applies the units(e.g., V for volts) `anchor` (default 'south west') specifies the position of the