2222
2323"""This module implements high level elements built on top of Spice elements."""
2424
25+ # Fixme: check NgSpice for discrepancies
26+
2527####################################################################################################
2628
2729from ..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
2931from ..Unit import as_s , as_V , as_A , as_Hz
3032from .BasicElement import VoltageSource , CurrentSource
3133
@@ -82,6 +84,8 @@ class SinusoidalMixin(SourceMixinAbc):
8284
8385 Public Attributes:
8486
87+ :attr:`ac_magnitude`
88+
8589 :attr:`amplitude`
8690
8791 :attr:`damping_factor`
@@ -100,10 +104,12 @@ class SinusoidalMixin(SourceMixinAbc):
100104
101105 def __init__ (self ,
102106 dc_offset = 0 ,
107+ ac_magnitude = 1 ,
103108 offset = 0 , amplitude = 1 , frequency = 50 ,
104109 delay = 0 , damping_factor = 0 ):
105110
106111 self .dc_offset = self .__as_unit__ (dc_offset )
112+ self .ac_magnitude = self .__as_unit__ (ac_magnitude )
107113 self .offset = self .__as_unit__ (offset )
108114 self .amplitude = self .__as_unit__ (amplitude )
109115 self .frequency = as_Hz (frequency ) # Fixme: protect by setter?
@@ -114,7 +120,8 @@ def __init__(self,
114120
115121 @property
116122 def rms_voltage (self ):
117- return amplitude_to_rms (self .amplitude )
123+ # Fixme: ok ???
124+ return amplitude_to_rms (self .amplitude * self .ac_magnitude )
118125
119126 ##############################################
120127
@@ -128,9 +135,8 @@ def format_spice_parameters(self):
128135
129136 sin_part = join_list ((self .offset , self .amplitude , self .frequency , self .delay , self .damping_factor ))
130137 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 ),
134140 ))
135141
136142####################################################################################################
0 commit comments