KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sim_model_source.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2022 Mikolaj Wielgus
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * https://www.gnu.org/licenses/gpl-3.0.html
20 * or you may search the http://www.gnu.org website for the version 3 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
26
27#include <fmt/core.h>
28#include <pegtl.hpp>
29#include <pegtl/contrib/parse_tree.hpp>
30
31
33{
34 using namespace SIM_MODEL_SOURCE_GRAMMAR;
35
36 template <typename Rule> struct pwlValuesSelector : std::false_type {};
37 template <> struct pwlValuesSelector<number<SIM_VALUE::TYPE_FLOAT, NOTATION::SI>>
38 : std::true_type {};
39}
40
41
42std::string SPICE_GENERATOR_SOURCE::ModelLine( const SPICE_ITEM& aItem ) const
43{
44 return "";
45}
46
47std::string SPICE_GENERATOR_SOURCE::TunerCommand( const SPICE_ITEM& aItem, double aValue ) const
48{
49 std::string result = "";
50
51 switch( aItem.model->GetType() )
52 {
53 case SIM_MODEL::TYPE::V: // VDC/IDC: it is clear which parameter should be used
54 case SIM_MODEL::TYPE::I:
55 result = fmt::format( "alter @{}={:g}",
56 aItem.model->SpiceGenerator().ItemName( aItem ),
57 aValue );
58 break;
59
60 default:
61 break; // other sources: unclear which parameter the user wants
62 }
63 return result;
64}
65
66std::string SPICE_GENERATOR_SOURCE::ItemLine( const SPICE_ITEM& aItem ) const
67{
68 SPICE_ITEM item = aItem;
69
70 std::string ac = "";
71 std::string dc = "";
72
73 if( const SIM_MODEL::PARAM* ac_param = m_model.FindParam( "ac" ) )
74 ac = SIM_VALUE::ToSpice( ac_param->value );
75 if( const SIM_MODEL::PARAM* dc_param = m_model.FindParam( "dc" ) )
76 dc = SIM_VALUE::ToSpice( dc_param->value );
77
78 bool emptyLine = true;
79 item.modelName = "";
80
81 // @FIXME
82 // the keyword "DC" refers to both offset of a sine source, and value for DC analysis
83 // Because of this, both values are always equal in a sine source.
84 //
85 // suggestion: rename the sine parameter from "DC" to "offset"
86
87 if( dc != "" )
88 {
89 emptyLine = false;
90 item.modelName += fmt::format( "DC {} ", dc );
91 }
92
93 if( m_model.GetSpiceInfo().functionName != ""
94 && m_model.GetType() != SIM_MODEL::TYPE::V // DC-only sources are already processed
95 && m_model.GetType() != SIM_MODEL::TYPE::I )
96 {
97 std::string args = "";
98
99 switch( m_model.GetType() )
100 {
101 case SIM_MODEL::TYPE::V_PWL:
102 case SIM_MODEL::TYPE::I_PWL:
103 {
104 tao::pegtl::string_input<> in( m_model.GetParam( 0 ).value, "from_content" );
105 std::unique_ptr<tao::pegtl::parse_tree::node> root;
106
107 try
108 {
109 root = tao::pegtl::parse_tree::parse<SIM_MODEL_SOURCE_PARSER::pwlValuesGrammar,
111 }
112 catch( const tao::pegtl::parse_error& )
113 {
114 break;
115 }
116
117 if( root )
118 {
119 for( const auto& node : root->children )
120 {
122 SIM_VALUE::NOTATION::SI>>() )
123 {
124 args.append( SIM_VALUE::ToSpice( node->string() ) + " " );
125 }
126 }
127 }
128
129 break;
130 }
131
132 case SIM_MODEL::TYPE::V_WHITENOISE:
133 case SIM_MODEL::TYPE::I_WHITENOISE:
134 args.append( getParamValueString( "rms", "0" ) + " " );
135 args.append( getParamValueString( "dt", "0" ) + " " );
136 args.append( "0 0 0 0 0 " );
137 break;
138
139 case SIM_MODEL::TYPE::V_PINKNOISE:
140 case SIM_MODEL::TYPE::I_PINKNOISE:
141 args.append( "0 " );
142 args.append( getParamValueString( "dt", "0" ) + " " );
143 args.append( getParamValueString( "slope", "0" ) + " " );
144 args.append( getParamValueString( "rms", "0" ) + " " );
145 args.append( "0 0 0 " );
146 break;
147
148 case SIM_MODEL::TYPE::V_BURSTNOISE:
149 case SIM_MODEL::TYPE::I_BURSTNOISE:
150 args.append( "0 0 0 0 " );
151 args.append( getParamValueString( "ampl", "0" ) + " " );
152 args.append( getParamValueString( "tcapt", "0" ) + " " );
153 args.append( getParamValueString( "temit", "0" ) + " " );
154 break;
155
156 case SIM_MODEL::TYPE::V_RANDUNIFORM:
157 case SIM_MODEL::TYPE::I_RANDUNIFORM:
158 {
159 args.append( "1 " );
160 args.append( getParamValueString( "ts", "0" ) + " " );
161 args.append( getParamValueString( "td", "0" ) + " " );
162 args.append( getParamValueString( "range", "1" ) + " " );
163 args.append( getParamValueString( "offset", "0" ) + " " );
164 break;
165 }
166
167 case SIM_MODEL::TYPE::V_RANDGAUSSIAN:
168 case SIM_MODEL::TYPE::I_RANDGAUSSIAN:
169 args.append( "2 " );
170 args.append( getParamValueString( "ts", "0" ) + " " );
171 args.append( getParamValueString( "td", "0" ) + " " );
172 args.append( getParamValueString( "stddev", "1" ) + " " );
173 args.append( getParamValueString( "mean", "0" ) + " " );
174 break;
175
176 case SIM_MODEL::TYPE::V_RANDEXP:
177 case SIM_MODEL::TYPE::I_RANDEXP:
178 args.append( "3 " );
179 args.append( getParamValueString( "ts", "0" ) + " " );
180 args.append( getParamValueString( "td", "0" ) + " " );
181 args.append( getParamValueString( "mean", "1" ) + " " );
182 args.append( getParamValueString( "offset", "0" ) + " " );
183 break;
184
185 case SIM_MODEL::TYPE::V_RANDPOISSON:
186 case SIM_MODEL::TYPE::I_RANDPOISSON:
187 args.append( "4 " );
188 args.append( getParamValueString( "ts", "0" ) + " " );
189 args.append( getParamValueString( "td", "0" ) + " " );
190 args.append( getParamValueString( "lambda", "1" ) + " " );
191 args.append( getParamValueString( "offset", "0" ) + " " );
192 break;
193
194 default:
195 for( int ii = 0; ii < m_model.GetParamCount(); ++ii )
196 {
197 const SIM_MODEL::PARAM& param = m_model.GetParam( ii );
198
199 if( ac != "" && ( param.Matches( "ac" ) || param.Matches( "ph" ) ) )
200 continue;
201
202 std::string argStr = SIM_VALUE::ToSpice( param.value );
203
204 if( argStr != "" )
205 args.append( argStr + " " );
206 }
207
208 break;
209 }
210
211 emptyLine = false;
212 item.modelName += fmt::format( "{}( {}) ", m_model.GetSpiceInfo().functionName, args );
213 }
214 else
215 {
216 switch( m_model.GetType() )
217 case SIM_MODEL::TYPE::V_VCL:
218 case SIM_MODEL::TYPE::I_VCL:
219 {
220 item.modelName += fmt::format( "{} ", getParamValueString( "gain", "1.0" ) );
221 emptyLine = false;
222
223 break;
224
225 case SIM_MODEL::TYPE::V_CCL:
226 case SIM_MODEL::TYPE::I_CCL:
227 item.modelName += fmt::format( "{} {} ",
228 getParamValueString( "control", "V?" ),
229 getParamValueString( "gain", "1.0" ) );
230 emptyLine = false;
231 break;
232
233 default:
234 break;
235 }
236 }
237
238 if( ac != "" )
239 {
240 std::string ph = "";
241
242 if( const SIM_MODEL::PARAM* ph_param = m_model.FindParam( "ph" ) )
243 ph = SIM_VALUE::ToSpice( ph_param->value );
244
245 emptyLine = false;
246 item.modelName += fmt::format( "AC {} {} ", ac, ph );
247 }
248
249 std::string portnum = "";
250
251 if( const SIM_MODEL::PARAM* portnum_param = m_model.FindParam( "portnum" ) )
252 portnum = SIM_VALUE::ToSpice( portnum_param->value );
253
254 if( portnum != "" )
255 {
256 item.modelName += fmt::format( "portnum {} ", portnum );
257
258 std::string z0 = "";
259
260 if( const SIM_MODEL::PARAM* z0_param = m_model.FindParam( "z0" ) )
261 z0 = SIM_VALUE::ToSpice( z0_param->value );
262
263 if( z0 != "" )
264 item.modelName += fmt::format( "z0 {} ", z0 );
265 }
266
267 if( emptyLine )
268 {
269 item.modelName = SIM_VALUE::ToSpice( m_model.GetParam( 0 ).value );
270 }
271
272 return SPICE_GENERATOR::ItemLine( item );
273}
274
275
276std::string SPICE_GENERATOR_SOURCE::getParamValueString( const std::string& aParamName,
277 const std::string& aDefaultValue ) const
278{
279 std::string result = "";
280
281 if ( m_model.FindParam( aParamName ) )
282 result = SIM_VALUE::ToSpice( m_model.FindParam( aParamName )->value );
283
284 if( result == "" )
285 result = aDefaultValue;
286
287 return result;
288}
289
290
292 SIM_MODEL( aType, std::make_unique<SPICE_GENERATOR_SOURCE>( *this ),
293 std::make_unique<SIM_MODEL_SOURCE_SERIALIZER>( *this ) )
294{
295 for( const SIM_MODEL::PARAM::INFO& paramInfo : makeParamInfos( aType ) )
296 AddParam( paramInfo );
297}
298
299
300void SIM_MODEL_SOURCE::doSetParamValue( int aParamIndex, const std::string& aValue )
301{
302 // Sources are special. All preceding parameter values must be filled. If they are not, fill
303 // them out automatically. If a value is nulled, delete everything after it.
304 if( aValue.empty() )
305 {
306 for( int paramIndex = aParamIndex; paramIndex < GetParamCount(); ++paramIndex )
307 {
308 m_params.at( aParamIndex ).value = "";
309 }
310 }
311 else
312 {
313 for( int paramIndex = 0; paramIndex < aParamIndex; ++paramIndex )
314 {
315 if( GetParam( paramIndex ).value == "" )
316 {
317 double dummy;
318 wxString defaultValue = m_params.at( aParamIndex ).info.defaultValue;
319
320 if( !defaultValue.ToDouble( &dummy ) )
321 defaultValue = wxT( "0" );
322
323 m_params.at( aParamIndex ).value = defaultValue;
324 SIM_MODEL::SetParamValue( paramIndex, defaultValue.ToStdString() );
325 }
326 }
327 }
328
329 return SIM_MODEL::doSetParamValue( aParamIndex, aValue );
330}
331
332
333const std::vector<SIM_MODEL::PARAM::INFO>& SIM_MODEL_SOURCE::makeParamInfos( TYPE aType )
334{
335 static std::vector<PARAM::INFO> vdc = makeDcParamInfos( "y", "V" );
336 static std::vector<PARAM::INFO> idc = makeDcParamInfos( "y", "A" );
337
338 static std::vector<PARAM::INFO> vsin = makeSinParamInfos( "y", "V" );
339 static std::vector<PARAM::INFO> isin = makeSinParamInfos( "y", "A" );
340
341 static std::vector<PARAM::INFO> vpulse = makePulseParamInfos( "y", "V" );
342 static std::vector<PARAM::INFO> ipulse = makePulseParamInfos( "y", "A" );
343
344 static std::vector<PARAM::INFO> vexp = makeExpParamInfos( "y", "V" );
345 static std::vector<PARAM::INFO> iexp = makeExpParamInfos( "y", "A" );
346
347 static std::vector<PARAM::INFO> vam = makeAMParamInfos( "y", "V" );
348 static std::vector<PARAM::INFO> iam = makeAMParamInfos( "y", "A" );
349
350 static std::vector<PARAM::INFO> vsffm = makeSFFMParamInfos( "y", "V" );
351 static std::vector<PARAM::INFO> isffm = makeSFFMParamInfos( "y", "A" );
352
353 static std::vector<PARAM::INFO> vcvs = makeVcParamInfos( "" );
354 static std::vector<PARAM::INFO> ccvs = makeCcParamInfos( "ohm" );
355 static std::vector<PARAM::INFO> vpwl = makePwlParamInfos( "y", "Voltage", "V" );
356
357 static std::vector<PARAM::INFO> vccs = makeVcParamInfos( "S" );
358 static std::vector<PARAM::INFO> cccs = makeCcParamInfos( "" );
359 static std::vector<PARAM::INFO> ipwl = makePwlParamInfos( "y", "Current", "A" );
360
361 static std::vector<PARAM::INFO> vwhitenoise = makeWhiteNoiseParamInfos( "y", "V" );
362 static std::vector<PARAM::INFO> iwhitenoise = makeWhiteNoiseParamInfos( "y", "A" );
363
364 static std::vector<PARAM::INFO> vpinknoise = makePinkNoiseParamInfos( "y", "V" );
365 static std::vector<PARAM::INFO> ipinknoise = makePinkNoiseParamInfos( "y", "A" );
366
367 static std::vector<PARAM::INFO> vburstnoise = makeBurstNoiseParamInfos( "y", "V" );
368 static std::vector<PARAM::INFO> iburstnoise = makeBurstNoiseParamInfos( "y", "A" );
369
370 static std::vector<PARAM::INFO> vrandomuniform = makeRandomUniformParamInfos( "y", "V" );
371 static std::vector<PARAM::INFO> irandomuniform = makeRandomUniformParamInfos( "y", "A" );
372
373 static std::vector<PARAM::INFO> vrandomnormal = makeRandomNormalParamInfos( "y", "V" );
374 static std::vector<PARAM::INFO> irandomnormal = makeRandomNormalParamInfos( "y", "A" );
375
376 static std::vector<PARAM::INFO> vrandomexp = makeRandomExpParamInfos( "y", "V" );
377 static std::vector<PARAM::INFO> irandomexp = makeRandomExpParamInfos( "y", "A" );
378
379 static std::vector<PARAM::INFO> vrandompoisson = makeRandomPoissonParamInfos( "y", "V" );
380 static std::vector<PARAM::INFO> irandompoisson = makeRandomPoissonParamInfos( "y", "A" );
381
382 switch( aType )
383 {
384 case TYPE::V: return vdc;
385 case TYPE::I: return idc;
386 case TYPE::V_SIN: return vsin;
387 case TYPE::I_SIN: return isin;
388 case TYPE::V_PULSE: return vpulse;
389 case TYPE::I_PULSE: return ipulse;
390 case TYPE::V_EXP: return vexp;
391 case TYPE::I_EXP: return iexp;
392 case TYPE::V_AM: return vam;
393 case TYPE::I_AM: return iam;
394 case TYPE::V_SFFM: return vsffm;
395 case TYPE::I_SFFM: return isffm;
396 case TYPE::V_VCL: return vcvs;
397 case TYPE::V_CCL: return ccvs;
398 case TYPE::V_PWL: return vpwl;
399 case TYPE::I_VCL: return vccs;
400 case TYPE::I_CCL: return cccs;
401 case TYPE::I_PWL: return ipwl;
402 case TYPE::V_WHITENOISE: return vwhitenoise;
403 case TYPE::I_WHITENOISE: return iwhitenoise;
404 case TYPE::V_PINKNOISE: return vpinknoise;
405 case TYPE::I_PINKNOISE: return ipinknoise;
406 case TYPE::V_BURSTNOISE: return vburstnoise;
407 case TYPE::I_BURSTNOISE: return iburstnoise;
408 case TYPE::V_RANDUNIFORM: return vrandomuniform;
409 case TYPE::I_RANDUNIFORM: return irandomuniform;
410 case TYPE::V_RANDGAUSSIAN: return vrandomnormal;
411 case TYPE::I_RANDGAUSSIAN: return irandomnormal;
412 case TYPE::V_RANDEXP: return vrandomexp;
413 case TYPE::I_RANDEXP: return irandomexp;
414 case TYPE::V_RANDPOISSON: return vrandompoisson;
415 case TYPE::I_RANDPOISSON: return irandompoisson;
416 default:
417 wxFAIL_MSG( "Unhandled SIM_MODEL type in SIM_MODEL_SOURCE" );
418 static std::vector<SIM_MODEL::PARAM::INFO> empty;
419 return empty;
420 }
421}
422
423
424std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makeDcParamInfos( const std::string& aPrefix,
425 const std::string& aUnit )
426{
427 std::vector<PARAM::INFO> paramInfos;
428 PARAM::INFO paramInfo;
429
430 paramInfo.name = "dc";
431 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
432 paramInfo.unit = aUnit;
433 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
434 paramInfo.defaultValue = "0";
435 paramInfo.description = "DC value";
436 paramInfos.push_back( paramInfo );
437
438 appendAcParamInfos( paramInfos, aUnit );
439 appendSpParamInfos( paramInfos, aUnit );
440 return paramInfos;
441}
442
443
444std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makeSinParamInfos( const std::string& aPrefix,
445 const std::string& aUnit )
446{
447 std::vector<PARAM::INFO> paramInfos;
448 PARAM::INFO paramInfo;
449
450 paramInfo.name = "dc";
451 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
452 paramInfo.unit = aUnit;
453 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
454 paramInfo.defaultValue = "";
455 paramInfo.description = "DC offset";
456 paramInfos.push_back( paramInfo );
457
458 paramInfo.name = "ampl";
459 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
460 paramInfo.unit = aUnit;
461 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
462 paramInfo.defaultValue = "";
463 paramInfo.description = "Amplitude";
464 paramInfos.push_back( paramInfo );
465
466 paramInfo.name = "f";
467 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
468 paramInfo.unit = "Hz";
469 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
470 paramInfo.defaultValue = "1/tstop";
471 paramInfo.description = "Frequency";
472 paramInfos.push_back( paramInfo );
473
474 paramInfo.name = "td";
475 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
476 paramInfo.unit = "s";
477 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
478 paramInfo.defaultValue = "0";
479 paramInfo.description = "Delay";
480 paramInfos.push_back( paramInfo );
481
482 paramInfo.name = "theta";
483 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
484 paramInfo.unit = "1/s";
485 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
486 paramInfo.defaultValue = "0";
487 paramInfo.description = "Damping factor";
488 paramInfos.push_back( paramInfo );
489
490 paramInfo.name = "phase";
491 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
492 paramInfo.unit = "°";
493 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
494 paramInfo.defaultValue = "0";
495 paramInfo.description = "Phase";
496 paramInfos.push_back( paramInfo );
497
498 appendAcParamInfos( paramInfos, aUnit );
499 appendSpParamInfos( paramInfos, aUnit );
500 return paramInfos;
501}
502
503
504std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makePulseParamInfos( const std::string& aPrefix,
505 const std::string& aUnit )
506{
507 std::vector<PARAM::INFO> paramInfos;
508 PARAM::INFO paramInfo;
509
510 paramInfo.name = aPrefix + "1";
511 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
512 paramInfo.unit = aUnit;
513 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
514 paramInfo.defaultValue = "";
515 paramInfo.description = "Initial value";
516 paramInfos.push_back( paramInfo );
517
518 paramInfo.name = aPrefix + "2";
519 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
520 paramInfo.unit = aUnit;
521 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
522 paramInfo.defaultValue = "";
523 paramInfo.description = "Pulsed value";
524 paramInfos.push_back( paramInfo );
525
526 paramInfo.name = "td";
527 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
528 paramInfo.unit = "s";
529 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
530 paramInfo.defaultValue = "0";
531 paramInfo.description = "Delay";
532 paramInfos.push_back( paramInfo );
533
534 paramInfo.name = "tr";
535 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
536 paramInfo.unit = "s";
537 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
538 paramInfo.defaultValue = "tstep";
539 paramInfo.description = "Rise time";
540 paramInfos.push_back( paramInfo );
541
542 paramInfo.name = "tf";
543 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
544 paramInfo.unit = "s";
545 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
546 paramInfo.defaultValue = "tstep";
547 paramInfo.description = "Fall time";
548 paramInfos.push_back( paramInfo );
549
550 paramInfo.name = "tw"; // Ngspice calls it "pw".
551 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
552 paramInfo.unit = "s";
553 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
554 paramInfo.defaultValue = "tstop";
555 paramInfo.description = "Pulse width";
556 paramInfos.push_back( paramInfo );
557
558 paramInfo.name = "per";
559 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
560 paramInfo.unit = "s";
561 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
562 paramInfo.defaultValue = "tstop";
563 paramInfo.description = "Period";
564 paramInfos.push_back( paramInfo );
565
566 paramInfo.name = "np";
567 paramInfo.type = SIM_VALUE::TYPE_INT;
568 paramInfo.unit = "";
569 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
570 paramInfo.defaultValue = "";
571 paramInfo.description = "Number of pulses";
572 paramInfos.push_back( paramInfo );
573
574 appendAcParamInfos( paramInfos, aUnit );
575 appendSpParamInfos( paramInfos, aUnit );
576 return paramInfos;
577}
578
579
580std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makeExpParamInfos( const std::string& aPrefix,
581 const std::string& aUnit )
582{
583 std::vector<PARAM::INFO> paramInfos;
584 PARAM::INFO paramInfo;
585
586 paramInfo.name = aPrefix + "1";
587 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
588 paramInfo.unit = aUnit;
589 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
590 paramInfo.defaultValue = "";
591 paramInfo.description = "Initial value";
592 paramInfos.push_back( paramInfo );
593
594 paramInfo.name = aPrefix + "2";
595 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
596 paramInfo.unit = aUnit;
597 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
598 paramInfo.defaultValue = "";
599 paramInfo.description = "Pulsed value";
600 paramInfos.push_back( paramInfo );
601
602 paramInfo.name = "td1";
603 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
604 paramInfo.unit = "s";
605 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
606 paramInfo.defaultValue = "0";
607 paramInfo.description = "Rise delay time";
608 paramInfos.push_back( paramInfo );
609
610 paramInfo.name = "tau1";
611 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
612 paramInfo.unit = "s";
613 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
614 paramInfo.defaultValue = "tstep";
615 paramInfo.description = "Rise time constant";
616 paramInfos.push_back( paramInfo );
617
618 paramInfo.name = "td2";
619 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
620 paramInfo.unit = "s";
621 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
622 paramInfo.defaultValue = "td1+tstep";
623 paramInfo.description = "Fall delay time";
624 paramInfos.push_back( paramInfo );
625
626 paramInfo.name = "tau2";
627 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
628 paramInfo.unit = "s";
629 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
630 paramInfo.defaultValue = "tstep";
631 paramInfo.description = "Fall time constant";
632 paramInfos.push_back( paramInfo );
633
634 appendAcParamInfos( paramInfos, aUnit );
635 appendSpParamInfos( paramInfos, aUnit );
636 return paramInfos;
637}
638
639
640std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makeAMParamInfos( const std::string& aPrefix,
641 const std::string& aUnit )
642{
643 std::vector<PARAM::INFO> paramInfos;
644 PARAM::INFO paramInfo;
645
646 paramInfo.name = "vo";
647 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
648 paramInfo.unit = aUnit;
649 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
650 paramInfo.defaultValue = "";
651 paramInfo.description = "Overall offset";
652 paramInfos.push_back( paramInfo );
653
654 paramInfo.name = "vmo";
655 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
656 paramInfo.unit = aUnit;
657 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
658 paramInfo.defaultValue = "";
659 paramInfo.description = "Modulation signal offset";
660 paramInfos.push_back( paramInfo );
661
662 paramInfo.name = "vma";
663 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
664 paramInfo.unit = aUnit;
665 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
666 paramInfo.defaultValue = "";
667 paramInfo.description = "Modulation signal amplitude";
668 paramInfos.push_back( paramInfo );
669
670 paramInfo.name = "fm";
671 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
672 paramInfo.unit = "Hz";
673 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
674 paramInfo.defaultValue = "5/tstop";
675 paramInfo.description = "Modulation signal frequency";
676 paramInfos.push_back( paramInfo );
677
678 paramInfo.name = "fc";
679 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
680 paramInfo.unit = "Hz";
681 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
682 paramInfo.defaultValue = "500/tstop";
683 paramInfo.description = "Carrier signal frequency";
684 paramInfos.push_back( paramInfo );
685
686 paramInfo.name = "td";
687 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
688 paramInfo.unit = "s";
689 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
690 paramInfo.defaultValue = "0";
691 paramInfo.description = "Overall delay";
692 paramInfos.push_back( paramInfo );
693
694 paramInfo.name = "phasem";
695 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
696 paramInfo.unit = "°";
697 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
698 paramInfo.defaultValue = "0";
699 paramInfo.description = "Modulation signal phase";
700 paramInfos.push_back( paramInfo );
701
702 paramInfo.name = "phasec";
703 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
704 paramInfo.unit = "°";
705 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
706 paramInfo.defaultValue = "0";
707 paramInfo.description = "Carrier signal phase";
708 paramInfos.push_back( paramInfo );
709
710 appendAcParamInfos( paramInfos, aUnit );
711 appendSpParamInfos( paramInfos, aUnit );
712 return paramInfos;
713}
714
715
716std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makeSFFMParamInfos( const std::string& aPrefix,
717 const std::string& aUnit )
718{
719 std::vector<PARAM::INFO> paramInfos;
720 PARAM::INFO paramInfo;
721
722 paramInfo.name = "vo";
723 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
724 paramInfo.unit = aUnit;
725 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
726 paramInfo.defaultValue = "";
727 paramInfo.description = "DC offset";
728 paramInfos.push_back( paramInfo );
729
730 paramInfo.name = "va";
731 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
732 paramInfo.unit = aUnit;
733 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
734 paramInfo.defaultValue = "";
735 paramInfo.description = "Amplitude";
736 paramInfos.push_back( paramInfo );
737
738 paramInfo.name = "fm";
739 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
740 paramInfo.unit = "Hz";
741 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
742 paramInfo.defaultValue = "5/tstop";
743 paramInfo.description = "Modulating frequency";
744 paramInfos.push_back( paramInfo );
745
746 paramInfo.name = "mdi";
747 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
748 paramInfo.unit = "";
749 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
750 paramInfo.defaultValue = "";
751 paramInfo.description = "Modulation index";
752 paramInfos.push_back( paramInfo );
753
754 paramInfo.name = "fc";
755 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
756 paramInfo.unit = "Hz";
757 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
758 paramInfo.defaultValue = "500/tstop";
759 paramInfo.description = "Carrier frequency";
760 paramInfos.push_back( paramInfo );
761
762 paramInfo.name = "phasem";
763 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
764 paramInfo.unit = "°";
765 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
766 paramInfo.defaultValue = "0";
767 paramInfo.description = "Modulating signal phase";
768 paramInfos.push_back( paramInfo );
769
770 paramInfo.name = "phasec";
771 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
772 paramInfo.unit = "°";
773 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
774 paramInfo.defaultValue = "0";
775 paramInfo.description = "Carrier signal phase";
776 paramInfos.push_back( paramInfo );
777
778 appendAcParamInfos( paramInfos, aUnit );
779 appendSpParamInfos( paramInfos, aUnit );
780 return paramInfos;
781}
782
783
784std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makeCcParamInfos( const std::string& aGainUnit )
785{
786 std::vector<PARAM::INFO> paramInfos;
787 PARAM::INFO paramInfo;
788
789 paramInfo.name = "gain";
790 paramInfo.id = 1;
791 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
792 paramInfo.unit = aGainUnit;
793 paramInfo.description = "Gain";
794 paramInfos.push_back( paramInfo );
795
796 paramInfo.name = "control";
797 paramInfo.id = 2;
798 paramInfo.type = SIM_VALUE::TYPE_STRING;
799 paramInfo.unit = "";
800 paramInfo.description = "Controlling voltage source";
801 paramInfos.push_back( paramInfo );
802
803 return paramInfos;
804}
805
806
807std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makeVcParamInfos( const std::string& aGainUnit )
808{
809 std::vector<PARAM::INFO> paramInfos;
810 PARAM::INFO paramInfo;
811
812 paramInfo.name = "gain";
813 paramInfo.id = 1;
814 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
815 paramInfo.unit = aGainUnit;
816 paramInfo.description = "Gain";
817 paramInfos.push_back( paramInfo );
818
819 return paramInfos;
820}
821
822
823std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makePwlParamInfos( const std::string& aPrefix,
824 const std::string& aQuantity,
825 const std::string& aUnit )
826{
827 std::vector<PARAM::INFO> paramInfos;
828 PARAM::INFO paramInfo;
829
830 paramInfo.name = "pwl";
831 paramInfo.type = SIM_VALUE::TYPE_STRING;
832 paramInfo.unit = "s," + aUnit;
833 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
834 paramInfo.defaultValue = "";
835 paramInfo.description = aUnit == "V" ? "Time-voltage points" : "Time-current points";
836 paramInfos.push_back( paramInfo );
837
838 appendAcParamInfos( paramInfos, aUnit );
839 appendSpParamInfos( paramInfos, aUnit );
840 return paramInfos;
841}
842
843
844std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makeWhiteNoiseParamInfos( const std::string& aPrefix,
845 const std::string& aUnit )
846{
847 std::vector<PARAM::INFO> paramInfos;
848 PARAM::INFO paramInfo;
849
850 paramInfo.name = "rms";
851 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
852 paramInfo.unit = aUnit;
853 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
854 paramInfo.defaultValue = "0";
855 paramInfo.description = "White noise RMS amplitude";
856 paramInfos.push_back( paramInfo );
857
858 paramInfo.name = "dt";
859 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
860 paramInfo.unit = "s";
861 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
862 paramInfo.defaultValue = "0";
863 paramInfo.description = "Time step";
864 paramInfos.push_back( paramInfo );
865
866 appendAcParamInfos( paramInfos, aUnit );
867 appendSpParamInfos( paramInfos, aUnit );
868 return paramInfos;
869}
870
871
872std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makePinkNoiseParamInfos( const std::string& aPrefix,
873 const std::string& aUnit )
874{
875 std::vector<PARAM::INFO> paramInfos;
876 PARAM::INFO paramInfo;
877
878 paramInfo.name = "rms";
879 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
880 paramInfo.unit = "";
881 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
882 paramInfo.defaultValue = "0";
883 paramInfo.description = "1/f noise RMS amplitude";
884 paramInfos.push_back( paramInfo );
885
886 paramInfo.name = "slope";
887 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
888 paramInfo.unit = "";
889 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
890 paramInfo.defaultValue = "1";
891 paramInfo.description = "1/f noise exponent";
892 paramInfos.push_back( paramInfo );
893
894 paramInfo.name = "dt";
895 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
896 paramInfo.unit = "s";
897 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
898 paramInfo.defaultValue = "0";
899 paramInfo.description = "Time step";
900 paramInfos.push_back( paramInfo );
901
902 appendAcParamInfos( paramInfos, aUnit );
903 appendSpParamInfos( paramInfos, aUnit );
904 return paramInfos;
905}
906
907
908std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makeBurstNoiseParamInfos( const std::string& aPrefix,
909 const std::string& aUnit )
910{
911 std::vector<PARAM::INFO> paramInfos;
912 PARAM::INFO paramInfo;
913
914 paramInfo.name = "ampl";
915 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
916 paramInfo.unit = aUnit;
917 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
918 paramInfo.defaultValue = "0";
919 paramInfo.description = "Burst noise amplitude";
920 paramInfos.push_back( paramInfo );
921
922 paramInfo.name = "tcapt";
923 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
924 paramInfo.unit = "s";
925 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
926 paramInfo.defaultValue = "0";
927 paramInfo.description = "Burst noise trap capture time";
928 paramInfos.push_back( paramInfo );
929
930 paramInfo.name = "temit";
931 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
932 paramInfo.unit = "s";
933 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
934 paramInfo.defaultValue = "0";
935 paramInfo.description = "Burst noise trap emission time";
936 paramInfos.push_back( paramInfo );
937
938 appendAcParamInfos( paramInfos, aUnit );
939 appendSpParamInfos( paramInfos, aUnit );
940 return paramInfos;
941}
942
943
944std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makeRandomUniformParamInfos( const std::string& aPrefix,
945 const std::string& aUnit )
946{
947 std::vector<PARAM::INFO> paramInfos;
948 PARAM::INFO paramInfo;
949
950 paramInfo.name = "ts";
951 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
952 paramInfo.unit = "s";
953 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
954 paramInfo.defaultValue = "";
955 paramInfo.description = "Individual voltage duration";
956 paramInfos.push_back( paramInfo );
957
958 paramInfo.name = "td";
959 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
960 paramInfo.unit = "s";
961 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
962 paramInfo.defaultValue = "0";
963 paramInfo.description = "Delay";
964 paramInfos.push_back( paramInfo );
965
966 paramInfo.name = "range";
967 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
968 paramInfo.unit = aUnit;
969 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
970 paramInfo.defaultValue = "1";
971 paramInfo.description = "Range";
972 paramInfos.push_back( paramInfo );
973
974 paramInfo.name = "offset";
975 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
976 paramInfo.unit = aUnit;
977 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
978 paramInfo.defaultValue = "0";
979 paramInfo.description = "Offset";
980 paramInfos.push_back( paramInfo );
981
982 appendAcParamInfos( paramInfos, aUnit );
983 appendSpParamInfos( paramInfos, aUnit );
984 return paramInfos;
985}
986
987
988std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makeRandomNormalParamInfos( const std::string& aPrefix,
989 const std::string& aUnit )
990{
991 std::vector<PARAM::INFO> paramInfos;
992 PARAM::INFO paramInfo;
993
994 paramInfo.name = "ts";
995 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
996 paramInfo.unit = "s";
997 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
998 paramInfo.defaultValue = "";
999 paramInfo.description = "Individual voltage duration";
1000 paramInfos.push_back( paramInfo );
1001
1002 paramInfo.name = "td";
1003 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1004 paramInfo.unit = "s";
1005 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
1006 paramInfo.defaultValue = "0";
1007 paramInfo.description = "Delay";
1008 paramInfos.push_back( paramInfo );
1009
1010 paramInfo.name = "stddev";
1011 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1012 paramInfo.unit = aUnit;
1013 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
1014 paramInfo.defaultValue = "1";
1015 paramInfo.description = "Standard deviation";
1016 paramInfos.push_back( paramInfo );
1017
1018 paramInfo.name = "mean";
1019 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1020 paramInfo.unit = aUnit;
1021 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
1022 paramInfo.defaultValue = "0";
1023 paramInfo.description = "Mean";
1024 paramInfos.push_back( paramInfo );
1025
1026 appendAcParamInfos( paramInfos, aUnit );
1027 appendSpParamInfos( paramInfos, aUnit );
1028 return paramInfos;
1029}
1030
1031
1032std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makeRandomExpParamInfos( const std::string& aPrefix,
1033 const std::string& aUnit )
1034{
1035 std::vector<PARAM::INFO> paramInfos;
1036 PARAM::INFO paramInfo;
1037
1038 paramInfo.name = "ts";
1039 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1040 paramInfo.unit = "s";
1041 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
1042 paramInfo.defaultValue = "";
1043 paramInfo.description = "Individual voltage duration";
1044 paramInfos.push_back( paramInfo );
1045
1046 paramInfo.name = "td";
1047 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1048 paramInfo.unit = "s";
1049 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
1050 paramInfo.defaultValue = "0";
1051 paramInfo.description = "Delay";
1052 paramInfos.push_back( paramInfo );
1053
1054 paramInfo.name = "mean";
1055 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1056 paramInfo.unit = aUnit;
1057 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
1058 paramInfo.defaultValue = "1";
1059 paramInfo.description = "Mean";
1060 paramInfos.push_back( paramInfo );
1061
1062 paramInfo.name = "offset";
1063 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1064 paramInfo.unit = aUnit;
1065 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
1066 paramInfo.defaultValue = "0";
1067 paramInfo.description = "Offset";
1068 paramInfos.push_back( paramInfo );
1069
1070 appendAcParamInfos( paramInfos, aUnit );
1071 appendSpParamInfos( paramInfos, aUnit );
1072 return paramInfos;
1073}
1074
1075
1076std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makeRandomPoissonParamInfos( const std::string& aPrefix,
1077 const std::string& aUnit )
1078{
1079 std::vector<PARAM::INFO> paramInfos;
1080 PARAM::INFO paramInfo;
1081
1082 paramInfo.name = "ts";
1083 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1084 paramInfo.unit = "s";
1085 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
1086 paramInfo.defaultValue = "";
1087 paramInfo.description = "Individual voltage duration";
1088 paramInfos.push_back( paramInfo );
1089
1090 paramInfo.name = "td";
1091 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1092 paramInfo.unit = "s";
1093 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
1094 paramInfo.defaultValue = "0";
1095 paramInfo.description = "Delay";
1096 paramInfos.push_back( paramInfo );
1097
1098 paramInfo.name = "lambda";
1099 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1100 paramInfo.unit = aUnit;
1101 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
1102 paramInfo.defaultValue = "1";
1103 paramInfo.description = "Lambda";
1104 paramInfos.push_back( paramInfo );
1105
1106 paramInfo.name = "offset";
1107 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1108 paramInfo.unit = aUnit;
1109 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
1110 paramInfo.defaultValue = "0";
1111 paramInfo.description = "Offset";
1112 paramInfos.push_back( paramInfo );
1113
1114 appendAcParamInfos( paramInfos, aUnit );
1115 appendSpParamInfos( paramInfos, aUnit );
1116 return paramInfos;
1117}
1118
1119void SIM_MODEL_SOURCE::appendAcParamInfos( std::vector<PARAM::INFO>& aParamInfos, const std::string& aUnit )
1120{
1121 PARAM::INFO paramInfo;
1122
1123 paramInfo.name = "ac";
1124 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1125 paramInfo.unit = aUnit;
1126 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::AC;
1127 paramInfo.defaultValue = "0";
1128 paramInfo.description = "AC magnitude";
1129 aParamInfos.push_back( paramInfo );
1130
1131 paramInfo.name = "ph";
1132 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1133 paramInfo.unit = "°";
1134 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::AC;
1135 paramInfo.defaultValue = "0";
1136 paramInfo.description = "AC phase";
1137 aParamInfos.push_back( paramInfo );
1138}
1139
1140void SIM_MODEL_SOURCE::appendSpParamInfos( std::vector<PARAM::INFO>& aParamInfos,
1141 const std::string& aUnit )
1142{
1143 PARAM::INFO paramInfo;
1144
1145 if( !strcmp( aUnit.c_str(), "V" ) )
1146 {
1147 paramInfo.name = "portnum";
1148 paramInfo.type = SIM_VALUE::TYPE_INT;
1149 paramInfo.unit = "";
1150 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::S_PARAM;
1151 paramInfo.defaultValue = "";
1152 paramInfo.description = "Port number";
1153 aParamInfos.push_back( paramInfo );
1154
1155 paramInfo.name = "z0";
1156 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1157 paramInfo.unit = "Ohm";
1158 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::S_PARAM;
1159 paramInfo.defaultValue = "";
1160 paramInfo.description = "Internal impedance";
1161 aParamInfos.push_back( paramInfo );
1162 }
1163}
1164
1165
1166std::vector<std::string> SIM_MODEL_SOURCE::GetPinNames() const
1167{
1168 if( GetDeviceType() == SIM_MODEL::DEVICE_T::E || GetDeviceType() == SIM_MODEL::DEVICE_T::G )
1169 return { "+", "-", "C+", "C-" };
1170 else
1171 return { "+", "-" };
1172}
1173
1175{
1176 switch( GetType() )
1177 {
1178 case SIM_MODEL::TYPE::V: // VDC/IDC: it is clear which parameter should be used
1179 case SIM_MODEL::TYPE::I:
1180 return &GetParam( 0 );
1181
1182 default:
1183 break; // other sources: unclear which parameter the user wants
1184 }
1185 return nullptr;
1186}
static void appendAcParamInfos(std::vector< PARAM::INFO > &aParamInfos, const std::string &aUnit)
static std::vector< PARAM::INFO > makeBurstNoiseParamInfos(const std::string &aPrefix, const std::string &aUnit)
std::vector< std::string > GetPinNames() const override
const PARAM * GetTunerParam() const override
static const std::vector< PARAM::INFO > & makeParamInfos(TYPE aType)
static std::vector< PARAM::INFO > makeExpParamInfos(const std::string &aPrefix, const std::string &aUnit)
static std::vector< PARAM::INFO > makeAMParamInfos(const std::string &aPrefix, const std::string &aUnit)
static std::vector< PARAM::INFO > makeRandomNormalParamInfos(const std::string &aPrefix, const std::string &aUnit)
static std::vector< SIM_MODEL::PARAM::INFO > makeVcParamInfos(const std::string &aGainUnit)
static void appendSpParamInfos(std::vector< PARAM::INFO > &aParamInfos, const std::string &aUnit)
SIM_MODEL_SOURCE(TYPE aType)
static std::vector< PARAM::INFO > makeRandomExpParamInfos(const std::string &aPrefix, const std::string &aUnit)
static std::vector< PARAM::INFO > makeSFFMParamInfos(const std::string &aPrefix, const std::string &aUnit)
static std::vector< PARAM::INFO > makeRandomUniformParamInfos(const std::string &aPrefix, const std::string &aUnit)
void doSetParamValue(int aParamIndex, const std::string &aValue) override
static std::vector< PARAM::INFO > makeRandomPoissonParamInfos(const std::string &aPrefix, const std::string &aUnit)
static std::vector< PARAM::INFO > makeDcParamInfos(const std::string &aPrefix, const std::string &aUnit)
static std::vector< PARAM::INFO > makePulseParamInfos(const std::string &aPrefix, const std::string &aUnit)
static std::vector< PARAM::INFO > makePinkNoiseParamInfos(const std::string &aPrefix, const std::string &aUnit)
static std::vector< PARAM::INFO > makeSinParamInfos(const std::string &aPrefix, const std::string &aUnit)
static std::vector< PARAM::INFO > makePwlParamInfos(const std::string &aPrefix, const std::string &aQuantity, const std::string &aUnit)
static std::vector< PARAM::INFO > makeWhiteNoiseParamInfos(const std::string &aPrefix, const std::string &aUnit)
static std::vector< SIM_MODEL::PARAM::INFO > makeCcParamInfos(const std::string &aGainUnit)
void AddParam(const PARAM::INFO &aInfo)
const SPICE_GENERATOR & SpiceGenerator() const
Definition sim_model.h:431
virtual const PARAM & GetParam(unsigned aParamIndex) const
SIM_MODEL()=delete
int GetParamCount() const
Definition sim_model.h:478
DEVICE_T GetDeviceType() const
Definition sim_model.h:460
virtual void doSetParamValue(int aParamIndex, const std::string &aValue)
std::vector< PARAM > m_params
Definition sim_model.h:535
void SetParamValue(int aParamIndex, const std::string &aValue, SIM_VALUE::NOTATION aNotation=SIM_VALUE::NOTATION::SI)
TYPE GetType() const
Definition sim_model.h:461
@ TYPE_STRING
Definition sim_value.h:71
static std::string ToSpice(const std::string &aString)
std::string ModelLine(const SPICE_ITEM &aItem) const override
std::string ItemLine(const SPICE_ITEM &aItem) const override
std::string TunerCommand(const SPICE_ITEM &aItem, double aValue) const override
std::string getParamValueString(const std::string &aParamName, const std::string &aDefaultValue) const
virtual std::string ItemName(const SPICE_ITEM &aItem) const
virtual std::string ItemLine(const SPICE_ITEM &aItem) const
const SIM_MODEL & m_model
static bool empty(const wxTextEntryBase *aCtrl)
STL namespace.
SIM_MODEL::TYPE TYPE
Definition sim_model.cpp:58
std::vector< FAB_LAYER_COLOR > dummy
std::string modelName
const SIM_MODEL * model
wxString result
Test unit parsing edge cases and error handling.