22
22
23
23
"""This module implements high level elements built on top of Spice elements."""
24
24
25
+ # Fixme: check NgSpice for discrepancies
26
+
25
27
####################################################################################################
26
28
27
29
from ..Math import rms_to_amplitude , amplitude_to_rms
28
- from ..Tools .StringTools import join_list , join_dict , str_spice
30
+ from ..Tools .StringTools import join_list , join_dict , str_spice , str_spice_list
29
31
from ..Unit import as_s , as_V , as_A , as_Hz
30
32
from .BasicElement import VoltageSource , CurrentSource
31
33
@@ -82,6 +84,8 @@ class SinusoidalMixin(SourceMixinAbc):
82
84
83
85
Public Attributes:
84
86
87
+ :attr:`ac_magnitude`
88
+
85
89
:attr:`amplitude`
86
90
87
91
:attr:`damping_factor`
@@ -100,10 +104,12 @@ class SinusoidalMixin(SourceMixinAbc):
100
104
101
105
def __init__ (self ,
102
106
dc_offset = 0 ,
107
+ ac_magnitude = 1 ,
103
108
offset = 0 , amplitude = 1 , frequency = 50 ,
104
109
delay = 0 , damping_factor = 0 ):
105
110
106
111
self .dc_offset = self .__as_unit__ (dc_offset )
112
+ self .ac_magnitude = self .__as_unit__ (ac_magnitude )
107
113
self .offset = self .__as_unit__ (offset )
108
114
self .amplitude = self .__as_unit__ (amplitude )
109
115
self .frequency = as_Hz (frequency ) # Fixme: protect by setter?
@@ -114,7 +120,8 @@ def __init__(self,
114
120
115
121
@property
116
122
def rms_voltage (self ):
117
- return amplitude_to_rms (self .amplitude )
123
+ # Fixme: ok ???
124
+ return amplitude_to_rms (self .amplitude * self .ac_magnitude )
118
125
119
126
##############################################
120
127
@@ -128,9 +135,8 @@ def format_spice_parameters(self):
128
135
129
136
sin_part = join_list ((self .offset , self .amplitude , self .frequency , self .delay , self .damping_factor ))
130
137
return join_list ((
131
- 'DC {}' .format (str_spice (self .dc_offset )),
132
- # 'AC SIN({})'.format(sin_part), # Fixme: To be fixed
133
- 'AC 1 SIN({})' .format (sin_part ),
138
+ 'DC {} AC {}' .format (* str_spice_list (self .dc_offset , self .ac_magnitude )),
139
+ 'SIN({})' .format (sin_part ),
134
140
))
135
141
136
142
####################################################################################################
0 commit comments