Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions PySpice/Spice/HighLevelElement.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,9 +557,9 @@ def format_spice_parameters(self):

if self.random_type == 'uniform':
random_type = 1
elif self.random_type == 'exponential':
random_type = 2
elif self.random_type == 'gaussian':
random_type = 2
elif self.random_type == 'exponential':
random_type = 3
elif self.random_type == 'poisson':
random_type = 4
Expand Down
15 changes: 15 additions & 0 deletions unit-test/Spice/test_HighLevelElement.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,21 @@ def test(self):
'Vpwl1 1 0 DC 50V PWL(0s 0V 10ms 0V 11ms 5V 20ms 5V r=12ms td=34ms)',
)

##############################################

def test_random_source_type_codes(self):

# ngspice TRRANDOM TYPE codes: 1 uniform, 2 gaussian, 3 exponential, 4 poisson
for random_type, code in (('uniform', 1), ('gaussian', 2),
('exponential', 3), ('poisson', 4)):
self._test_spice_declaration(
RandomVoltageSource(
Circuit(''), 'rand1', '1', '0',
random_type=random_type, duration=1@u_ms,
),
'Vrand1 1 0 TRRANDOM({} 1ms 0s 1 0)'.format(code),
)

####################################################################################################

if __name__ == '__main__':
Expand Down