KiCad PCB EDA Suite
Loading...
Searching...
No Matches
spice_simulator.h
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) 2016 CERN
5 * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * @author Tomasz Wlostowski <[email protected]>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 3
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, you may find one here:
21 * https://www.gnu.org/licenses/gpl-3.0.html
22 * or you may search the http://www.gnu.org website for the version 3 license,
23 * or you may write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 */
26
27#ifndef SPICE_SIMULATOR_H
28#define SPICE_SIMULATOR_H
29
30#include "sim_types.h"
31#include "spice_settings.h"
32#include "simulator.h"
33
34#include <mutex>
35#include <string>
36#include <vector>
37#include <complex>
38#include <memory>
39
40#include <wx/string.h>
41
43
44typedef std::complex<double> COMPLEX;
45
46
48{
49public:
51 SIMULATOR(),
52 m_reporter( nullptr ),
53 m_settings( nullptr )
54 {}
55
56 virtual ~SPICE_SIMULATOR() {}
57
58 /*
59 * Initialize the simulator using the optional \a aSettings.
60 *
61 * @param aSettings [in] are the simulator specific settings. Can be null if no settings need
62 * to be initialized.
63 */
64 virtual void Init( const SPICE_SETTINGS* aSettings = nullptr ) = 0;
65
71 virtual bool LoadNetlist( const std::string& aNetlist ) = 0;
72
78 virtual bool Command( const std::string& aCmd ) = 0;
79
81 virtual wxString GetXAxis( SIM_TYPE aType ) const = 0;
82
84 virtual void SetReporter( SIMULATOR_REPORTER* aReporter )
85 {
86 m_reporter = aReporter;
87 }
88
92 virtual wxString CurrentPlotName() const = 0;
93
97 virtual std::vector<std::string> AllVectors() const = 0;
98
108 virtual std::vector<COMPLEX> GetComplexVector( const std::string& aName, int aMaxLen = -1 ) = 0;
109
119 virtual std::vector<double> GetRealVector( const std::string& aName, int aMaxLen = -1 ) = 0;
120
130 virtual std::vector<double> GetImaginaryVector( const std::string& aName, int aMaxLen = -1 ) = 0;
131
140 virtual std::vector<double> GetGainVector( const std::string& aName, int aMaxLen = -1 ) = 0;
141
150 virtual std::vector<double> GetPhaseVector( const std::string& aName, int aMaxLen = -1 ) = 0;
151
157 virtual const std::string GetNetlist() const = 0;
158
162 virtual std::vector<std::string> GetSettingCommands() const = 0;
163
169 std::shared_ptr<SPICE_SETTINGS>& Settings() { return m_settings; }
170
171 const std::shared_ptr<SPICE_SETTINGS>& Settings() const { return m_settings; }
172
181 static wxString TypeToName( SIM_TYPE aType, bool aShortName );
182
183protected:
186
188 std::shared_ptr<SPICE_SETTINGS> m_settings;
189};
190
191#endif /* SPICE_SIMULATOR_H */
Interface to receive simulation updates from SPICE_SIMULATOR class.
Storage for simulator specific settings.
virtual std::vector< double > GetImaginaryVector(const std::string &aName, int aMaxLen=-1)=0
Return a requested vector with imaginary values.
virtual void Init(const SPICE_SETTINGS *aSettings=nullptr)=0
virtual bool Command(const std::string &aCmd)=0
Execute a Spice command as if it was typed into console.
virtual bool LoadNetlist(const std::string &aNetlist)=0
Load a netlist for the simulation.
static wxString TypeToName(SIM_TYPE aType, bool aShortName)
Return a string with simulation name based on enum.
virtual wxString GetXAxis(SIM_TYPE aType) const =0
Set a SIMULATOR_REPORTER object to receive the simulation log.
virtual std::vector< COMPLEX > GetComplexVector(const std::string &aName, int aMaxLen=-1)=0
Return a requested vector with complex values.
std::shared_ptr< SPICE_SETTINGS > & Settings()
Return the simulator configuration settings.
const std::shared_ptr< SPICE_SETTINGS > & Settings() const
virtual wxString CurrentPlotName() const =0
virtual const std::string GetNetlist() const =0
Return current SPICE netlist used by the simulator.
virtual std::vector< std::string > AllVectors() const =0
virtual std::vector< std::string > GetSettingCommands() const =0
virtual std::vector< double > GetRealVector(const std::string &aName, int aMaxLen=-1)=0
Return a requested vector with real values.
SIMULATOR_REPORTER * m_reporter
< Reporter object to receive simulation log.
virtual void SetReporter(SIMULATOR_REPORTER *aReporter)
virtual std::vector< double > GetGainVector(const std::string &aName, int aMaxLen=-1)=0
Return a requested vector with magnitude values.
virtual ~SPICE_SIMULATOR()
std::shared_ptr< SPICE_SETTINGS > m_settings
virtual std::vector< double > GetPhaseVector(const std::string &aName, int aMaxLen=-1)=0
Return a requested vector with phase values.
SIM_TYPE
< Possible simulation types
Definition: sim_types.h:32
std::complex< double > COMPLEX