Undo hardcoding swapping of diode pins
Revert commitsd1e2acd3
70b4d1aa
cff508fb
This commit is contained in:
parent
a2679f62cd
commit
5eca8dd8de
|
@ -284,7 +284,6 @@ set( EESCHEMA_SRCS
|
|||
sim/sim_lib_mgr.cpp
|
||||
sim/sim_model.cpp
|
||||
sim/sim_model_behavioral.cpp
|
||||
sim/sim_model_diode.cpp
|
||||
sim/sim_model_ideal.cpp
|
||||
sim/sim_model_mutual_inductor.cpp
|
||||
sim/sim_model_kibis.cpp
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
|
||||
#include <sim/sim_model.h>
|
||||
#include <sim/sim_model_behavioral.h>
|
||||
#include <sim/sim_model_diode.h>
|
||||
#include <sim/sim_model_ideal.h>
|
||||
#include <sim/sim_model_mutual_inductor.h>
|
||||
#include <sim/sim_model_ngspice.h>
|
||||
|
@ -916,9 +915,6 @@ std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( TYPE aType )
|
|||
case TYPE::SW_I:
|
||||
return std::make_unique<SIM_MODEL_SWITCH>( aType );
|
||||
|
||||
case TYPE::D:
|
||||
return std::make_unique<SIM_MODEL_DIODE>();
|
||||
|
||||
case TYPE::V:
|
||||
case TYPE::I:
|
||||
case TYPE::V_SIN:
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2022 Mikolaj Wielgus
|
||||
* Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 3
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* https://www.gnu.org/licenses/gpl-3.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 3 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <sim/sim_model_diode.h>
|
||||
|
||||
|
||||
std::string SPICE_GENERATOR_DIODE::ItemLine( const SPICE_ITEM& aItem ) const
|
||||
{
|
||||
SPICE_ITEM item = aItem;
|
||||
|
||||
// FIXME: This `if` is there because Preview() calls this function with empty pinNetNames vector.
|
||||
// This shouldn't be necessary.
|
||||
if( item.pinNetNames.size() >= 2 )
|
||||
std::swap( item.pinNetNames.at( 0 ), item.pinNetNames.at( 1 ) );
|
||||
|
||||
return SPICE_GENERATOR::ItemLine( item );
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string> SPICE_GENERATOR_DIODE::CurrentNames( const SPICE_ITEM& aItem ) const
|
||||
{
|
||||
return SPICE_GENERATOR::CurrentNames( aItem ); // NOLINT
|
||||
}
|
||||
|
||||
|
||||
SIM_MODEL_DIODE::SIM_MODEL_DIODE() :
|
||||
SIM_MODEL_NGSPICE( TYPE::D, std::make_unique<SPICE_GENERATOR_DIODE>( *this ) )
|
||||
{
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2022 Mikolaj Wielgus
|
||||
* Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 3
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* https://www.gnu.org/licenses/gpl-3.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 3 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef SIM_MODEL_DIODE_H
|
||||
#define SIM_MODEL_DIODE_H
|
||||
|
||||
#include <sim/sim_model_ngspice.h>
|
||||
|
||||
|
||||
class SPICE_GENERATOR_DIODE : public SPICE_GENERATOR_NGSPICE
|
||||
{
|
||||
public:
|
||||
using SPICE_GENERATOR_NGSPICE::SPICE_GENERATOR_NGSPICE;
|
||||
|
||||
std::string ItemLine( const SPICE_ITEM& aItem ) const override;
|
||||
std::vector<std::string> CurrentNames( const SPICE_ITEM& aItem ) const override;
|
||||
};
|
||||
|
||||
|
||||
class SIM_MODEL_DIODE : public SIM_MODEL_NGSPICE
|
||||
{
|
||||
public:
|
||||
SIM_MODEL_DIODE();
|
||||
};
|
||||
|
||||
#endif // SIM_MODEL_DIODE_H
|
|
@ -48,6 +48,12 @@ std::vector<std::string> SPICE_GENERATOR_NGSPICE::CurrentNames( const SPICE_ITEM
|
|||
fmt::format( "I({}:g)", aItem.refName ),
|
||||
fmt::format( "I({}:s)", aItem.refName ) };
|
||||
|
||||
case SIM_MODEL::DEVICE_TYPE_::R:
|
||||
case SIM_MODEL::DEVICE_TYPE_::C:
|
||||
case SIM_MODEL::DEVICE_TYPE_::L:
|
||||
case SIM_MODEL::DEVICE_TYPE_::D:
|
||||
return SPICE_GENERATOR::CurrentNames( aItem );
|
||||
|
||||
default:
|
||||
wxFAIL_MSG( "Unhandled model device type in SIM_MODEL_NGSPICE" );
|
||||
return {};
|
||||
|
@ -56,8 +62,22 @@ std::vector<std::string> SPICE_GENERATOR_NGSPICE::CurrentNames( const SPICE_ITEM
|
|||
|
||||
|
||||
SIM_MODEL_NGSPICE::SIM_MODEL_NGSPICE( TYPE aType ) :
|
||||
SIM_MODEL_NGSPICE( aType, std::make_unique<SPICE_GENERATOR_NGSPICE>( *this ) )
|
||||
SIM_MODEL_SPICE( aType, std::make_unique<SPICE_GENERATOR_NGSPICE>( *this ) )
|
||||
{
|
||||
const MODEL_INFO& modelInfo = ModelInfo( getModelType() );
|
||||
|
||||
for( const SIM_MODEL::PARAM::INFO& paramInfo : modelInfo.instanceParams )
|
||||
{
|
||||
// For now, only the geometry parameters.
|
||||
if( paramInfo.category == SIM_MODEL::PARAM::CATEGORY::PRINCIPAL
|
||||
|| paramInfo.category == SIM_MODEL::PARAM::CATEGORY::GEOMETRY )
|
||||
{
|
||||
AddParam( paramInfo, getIsOtherVariant() );
|
||||
}
|
||||
}
|
||||
|
||||
for( const SIM_MODEL::PARAM::INFO& paramInfo : modelInfo.modelParams )
|
||||
AddParam( paramInfo, getIsOtherVariant() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -141,27 +161,6 @@ void SIM_MODEL_NGSPICE::SetParamFromSpiceCode( const std::string& aParamName,
|
|||
}
|
||||
|
||||
|
||||
SIM_MODEL_NGSPICE::SIM_MODEL_NGSPICE( TYPE aType,
|
||||
std::unique_ptr<SPICE_GENERATOR> aSpiceGenerator ) :
|
||||
SIM_MODEL_SPICE( aType, std::move( aSpiceGenerator ) )
|
||||
{
|
||||
const MODEL_INFO& modelInfo = ModelInfo( getModelType() );
|
||||
|
||||
for( const SIM_MODEL::PARAM::INFO& paramInfo : modelInfo.instanceParams )
|
||||
{
|
||||
// For now, only the geometry parameters.
|
||||
if( paramInfo.category == SIM_MODEL::PARAM::CATEGORY::PRINCIPAL
|
||||
|| paramInfo.category == SIM_MODEL::PARAM::CATEGORY::GEOMETRY )
|
||||
{
|
||||
AddParam( paramInfo, getIsOtherVariant() );
|
||||
}
|
||||
}
|
||||
|
||||
for( const SIM_MODEL::PARAM::INFO& paramInfo : modelInfo.modelParams )
|
||||
AddParam( paramInfo, getIsOtherVariant() );
|
||||
}
|
||||
|
||||
|
||||
bool SIM_MODEL_NGSPICE::canSilentlyIgnoreParam( const std::string& aParamName )
|
||||
{
|
||||
// Ignore the purely informative LTspice-specific parameters "mfg" and "type".
|
||||
|
|
|
@ -103,8 +103,6 @@ protected:
|
|||
|
||||
static const MODEL_INFO& ModelInfo( MODEL_TYPE aType );
|
||||
|
||||
SIM_MODEL_NGSPICE( TYPE aType, std::unique_ptr<SPICE_GENERATOR> aSpiceGenerator );
|
||||
|
||||
private:
|
||||
bool requiresSpiceModelLine() const override { return false; }
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ struct MODEL_INFO_MAP
|
|||
modelInfos[MODEL_TYPE::CSWITCH].instanceParams.emplace_back( "p", 7, SIM_MODEL::PARAM::DIR_OUT, SIM_VALUE::TYPE_FLOAT, SIM_MODEL::PARAM::FLAGS(), "", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "", "", "Instantaneous power", true );*/
|
||||
|
||||
|
||||
modelInfos[MODEL_TYPE::DIODE] = { "Diode", "D", "", { "Cathode", "Anode" }, "Junction Diode model", {}, {} };
|
||||
modelInfos[MODEL_TYPE::DIODE] = { "Diode", "D", "", { "Anode", "Cathode" }, "Junction Diode model", {}, {} };
|
||||
// Model parameters
|
||||
modelInfos[MODEL_TYPE::DIODE].modelParams.emplace_back( "level", 100, SIM_MODEL::PARAM::DIR_INOUT, SIM_VALUE::TYPE_INT, SIM_MODEL::PARAM::FLAGS(), "", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "1", "", "Diode level selector" );
|
||||
modelInfos[MODEL_TYPE::DIODE].modelParams.emplace_back( "is", 101, SIM_MODEL::PARAM::DIR_INOUT, SIM_VALUE::TYPE_FLOAT, SIM_MODEL::PARAM::FLAGS(), "A", SIM_MODEL::PARAM::CATEGORY::DC, "1e-14", "", "Saturation current" );
|
||||
|
|
|
@ -185,11 +185,11 @@
|
|||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(symbol "VSIN_0_0"
|
||||
(arc (start 0 0) (mid -0.635 0.6323) (end -1.27 0)
|
||||
(arc (start 0 0) (mid -0.635 0.635) (end -1.27 0)
|
||||
(stroke (width 0) (type default))
|
||||
(fill (type none))
|
||||
)
|
||||
(arc (start 0 0) (mid 0.635 -0.6323) (end 1.27 0)
|
||||
(arc (start 0 0) (mid 0.635 -0.635) (end 1.27 0)
|
||||
(stroke (width 0) (type default))
|
||||
(fill (type none))
|
||||
)
|
||||
|
@ -400,7 +400,7 @@
|
|||
(property "Datasheet" "~" (at 151.765 96.52 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Sim_Device" "D" (at 151.765 96.52 0)
|
||||
(property "Sim_Device" "DIODE" (at 151.765 96.52 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Sim_Name" "DIODE1" (at 151.765 96.52 0)
|
||||
|
@ -409,6 +409,9 @@
|
|||
(property "Sim_Library" "diode.lib" (at 151.765 96.52 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Sim_Pins" "2 1" (at 151.765 96.52 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(pin "1" (uuid cb1986eb-8b78-41be-ab05-5001090a2a65))
|
||||
(pin "2" (uuid edfbe61b-6d1d-45a6-bfef-e48a694e79db))
|
||||
(instances
|
||||
|
|
Loading…
Reference in New Issue