KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sim_model_l_mutual.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, see <https://www.gnu.org/licenses/>.
19 */
20
22
23
25{
26 std::string result;
27
28 for( int ii = 0; ii < m_model.GetParamCount(); ++ii )
29 {
30 const SIM_MODEL::PARAM& param = m_model.GetParam( ii );
31
32 if( !param.info.isSpiceInstanceParam )
33 continue;
34
35 result.append( " " + SIM_VALUE::ToSpice( param.value ) );
36 }
37
38 return result;
39}
40
41
43 SIM_MODEL( SIM_MODEL::TYPE::K, std::make_unique<SPICE_GENERATOR_L_MUTUAL>( *this ) )
44{
45 static std::vector<PARAM::INFO> paramInfos = makeParamInfos();
46
47 for( const PARAM::INFO& paramInfo : paramInfos )
48 AddParam( paramInfo );
49}
50
51
52const std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_L_MUTUAL::makeParamInfos()
53{
54 std::vector<PARAM::INFO> paramInfos;
55 PARAM::INFO paramInfo;
56
57 paramInfo.name = "l1";
58 paramInfo.type = SIM_VALUE::TYPE_STRING;
59 paramInfo.unit = "(Reference)";
60 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
61 paramInfo.defaultValue = "";
62 paramInfo.description = "Inductor 1";
63 paramInfo.isSpiceInstanceParam = true;
64 paramInfos.push_back( paramInfo );
65
66 paramInfo.name = "l2";
67 paramInfo.type = SIM_VALUE::TYPE_STRING;
68 paramInfo.unit = "(Reference)";
69 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
70 paramInfo.defaultValue = "";
71 paramInfo.description = "Inductor 2";
72 paramInfo.isSpiceInstanceParam = true;
73 paramInfos.push_back( paramInfo );
74
75 paramInfo.name = "k";
76 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
77 paramInfo.unit = "";
78 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
79 paramInfo.defaultValue = "";
80 paramInfo.description = "Coupling coefficient";
81 paramInfo.isSpiceInstanceParam = true;
82 paramInfos.push_back( paramInfo );
83
84 return paramInfos;
85}
static const std::vector< PARAM::INFO > makeParamInfos()
void AddParam(const PARAM::INFO &aInfo)
SIM_MODEL()=delete
@ TYPE_STRING
Definition sim_value.h:67
static std::string ToSpice(const std::string &aString)
std::string ItemParams() const override
const SIM_MODEL & m_model
STL namespace.
SIM_MODEL::TYPE TYPE
Definition sim_model.cpp:54
std::string value
Definition sim_model.h:397
const INFO & info
Definition sim_model.h:398
wxString result
Test unit parsing edge cases and error handling.