Changeset a0d8aa for src


Ignore:
Timestamp:
Aug 30, 2025, 2:41:40 PM (2 months ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
Candidate_v1.7.0, stable
Children:
a4b917
Parents:
e83114
git-author:
Frederik Heber <frederik.heber@…> (08/17/25 20:24:43)
git-committer:
Frederik Heber <frederik.heber@…> (08/30/25 14:41:40)
Message:

PotentialFactory exposes particle type numbers.

  • Also, potentials use getParticleTypeNumber() in asserts.
Location:
src/Potentials
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • src/Potentials/PotentialFactory.cpp

    re83114 ra0d8aa  
    108108      "PotentialFactory::getNameForType() - cannot find potential of name "+_type);
    109109  return TypeToName[_type];
     110}
     111
     112unsigned int PotentialFactory::getPotentialsParticleTypeNumber(const std::string &_name) const {
     113        EmpiricalPotential * const defaultPotential = getDefaultPotential(_name);
     114        if (defaultPotential == NULL)
     115                return 0;
     116        const unsigned int particleTypeNumber = defaultPotential->getParticleTypeNumber();
     117        delete defaultPotential;
     118        return particleTypeNumber;
    110119}
    111120
     
    207216}
    208217
    209 
    210218CONSTRUCT_SINGLETON(PotentialFactory)
  • src/Potentials/PotentialFactory.hpp

    re83114 ra0d8aa  
    6969                        const FunctionModel::parameters_t &params) const;
    7070
     71  /** Returns the number of particle types for the given potential.
     72   *
     73   * \param _name name of the potential
     74   * \return number of particle types needed by the potential, 0 if potential unknown
     75   */
     76  unsigned int getPotentialsParticleTypeNumber(const std::string &_name) const;
     77
    7178  //!> typedef for map to lookup type for a given name
    7279  typedef std::map< std::string, enum PotentialTypes > NameToType_t;
  • src/Potentials/Specifics/ConstantPotential.cpp

    re83114 ra0d8aa  
    6565Coordinator::ptr ConstantPotential::coordinator( /* Memory::ignore( */ new OneBody_Constant() /*) */);
    6666
    67 static BindingModel generateBindingModel(const EmpiricalPotential::ParticleTypes_t &_ParticleTypes)
     67BindingModel ConstantPotential::generateBindingModel(const EmpiricalPotential::ParticleTypes_t &_ParticleTypes) const
    6868{
    6969  // fill nodes
    70   ASSERT( _ParticleTypes.size() <= (size_t)1,
     70  ASSERT( _ParticleTypes.size() <= (size_t)getParticleTypeNumber(),
    7171      "generateBindingModel() - ConstantPotential needs zero or one type.");
    7272  BindingModel::vector_nodes_t nodes;
  • src/Potentials/Specifics/ConstantPotential.hpp

    re83114 ra0d8aa  
    5252  ConstantPotential();
    5353
     54  /** Creates the binding model specific for this potential.
     55   *
     56   * Private because this is used internally some of the constructors.
     57   *
     58   * \param _ParticleTypes particle type for the potential
     59   * \return binding model
     60   */
     61  BindingModel generateBindingModel(const EmpiricalPotential::ParticleTypes_t &_ParticleTypes) const;
     62
    5463public:
    5564  ConstantPotential(const ParticleTypes_t &_ParticleTypes);
  • src/Potentials/Specifics/FourBodyPotential_Improper.cpp

    re83114 ra0d8aa  
    5353Coordinator::ptr FourBodyPotential_Improper::coordinator( /* Memory::ignore( */ new FourBody_ImproperAngle() /* ) */ );
    5454
    55 static BindingModel generateBindingModel(const EmpiricalPotential::ParticleTypes_t &_ParticleTypes)
     55BindingModel FourBodyPotential_Improper::generateBindingModel(const EmpiricalPotential::ParticleTypes_t &_ParticleTypes) const
    5656{
    5757  // fill nodes
    5858  BindingModel::vector_nodes_t nodes;
    5959  {
    60     ASSERT( _ParticleTypes.size() == (size_t)4,
     60    ASSERT( _ParticleTypes.size() == (size_t)getParticleTypeNumber(),
    6161        "generateBindingModel() - FourBodyPotential_Improper needs four types.");
    6262    nodes.push_back( FragmentNode(_ParticleTypes[0], 3) );
  • src/Potentials/Specifics/FourBodyPotential_Improper.hpp

    re83114 ra0d8aa  
    4343   */
    4444  FourBodyPotential_Improper();
     45
     46  /** Creates the binding model specific for this potential.
     47   *
     48   * Private because this is used internally some of the constructors.
     49   *
     50   * \param _ParticleTypes particle type for the potential
     51   * \return binding model
     52   */
     53  BindingModel generateBindingModel(const EmpiricalPotential::ParticleTypes_t &_ParticleTypes) const;
    4554
    4655  /** Returns the functor that converts argument_s into the
  • src/Potentials/Specifics/FourBodyPotential_Torsion.cpp

    re83114 ra0d8aa  
    6666Coordinator::ptr FourBodyPotential_Torsion::coordinator( /* Memory::ignore( */ new FourBody_TorsionAngle() /* ) */ );
    6767
    68 static BindingModel generateBindingModel(const EmpiricalPotential::ParticleTypes_t &_ParticleTypes)
     68BindingModel FourBodyPotential_Torsion::generateBindingModel(const EmpiricalPotential::ParticleTypes_t &_ParticleTypes) const
    6969{
    7070  // fill nodes
    7171  BindingModel::vector_nodes_t nodes;
    7272  {
    73     ASSERT( _ParticleTypes.size() == (size_t)4,
     73    ASSERT( _ParticleTypes.size() == (size_t)getParticleTypeNumber(),
    7474        "generateBindingModel() - FourBodyPotential_Torsion needs four types.");
    7575    nodes.push_back( FragmentNode(_ParticleTypes[0], 1) );
  • src/Potentials/Specifics/FourBodyPotential_Torsion.hpp

    re83114 ra0d8aa  
    5353  FourBodyPotential_Torsion();
    5454
     55  /** Creates the binding model specific for this potential.
     56   *
     57   * Private because this is used internally some of the constructors.
     58   *
     59   * \param _ParticleTypes particle type for the potential
     60   * \return binding model
     61   */
     62  BindingModel generateBindingModel(const EmpiricalPotential::ParticleTypes_t &_ParticleTypes) const;
     63
    5564public:
    5665  FourBodyPotential_Torsion(const ParticleTypes_t &_ParticleTypes);
  • src/Potentials/Specifics/ManyBodyPotential_Tersoff.cpp

    re83114 ra0d8aa  
    8282Coordinator::ptr ManyBodyPotential_Tersoff::coordinator( /* Memory::ignore( */ new OneBody_Constant() /* ) */ );
    8383
    84 static BindingModel generateBindingModel(const EmpiricalPotential::ParticleTypes_t &_ParticleTypes)
     84BindingModel ManyBodyPotential_Tersoff::generateBindingModel(const EmpiricalPotential::ParticleTypes_t &_ParticleTypes) const
    8585{
    8686  // fill nodes
    8787  BindingModel::vector_nodes_t nodes;
    8888  {
    89     ASSERT( _ParticleTypes.size() == (size_t)2,
     89    ASSERT( _ParticleTypes.size() == (size_t)getParticleTypeNumber(),
    9090        "generateBindingModel() - ManyBodyPotential_Tersoff needs two types.");
    9191    nodes.push_back( FragmentNode(_ParticleTypes[0], 1) );
  • src/Potentials/Specifics/ManyBodyPotential_Tersoff.hpp

    re83114 ra0d8aa  
    5252  ManyBodyPotential_Tersoff();
    5353
     54  /** Creates the binding model specific for this potential.
     55   *
     56   * Private because this is used internally some of the constructors.
     57   *
     58   * \param _ParticleTypes particle type for the potential
     59   * \return binding model
     60   */
     61  BindingModel generateBindingModel(const EmpiricalPotential::ParticleTypes_t &_ParticleTypes) const;
     62
    5463public:
    5564  /** Constructor for class ManyBodyPotential_Tersoff.
  • src/Potentials/Specifics/PairPotential_Harmonic.cpp

    re83114 ra0d8aa  
    6767Coordinator::ptr PairPotential_Harmonic::coordinator( /* Memory::ignore( */ new TwoBody_Length() /* ) */ );
    6868
    69 static BindingModel generateBindingModel(const EmpiricalPotential::ParticleTypes_t &_ParticleTypes)
     69BindingModel PairPotential_Harmonic::generateBindingModel(const EmpiricalPotential::ParticleTypes_t &_ParticleTypes) const
    7070{
    7171  // fill nodes
    7272  BindingModel::vector_nodes_t nodes;
    7373  {
    74     ASSERT( _ParticleTypes.size() == (size_t)2,
     74    ASSERT( _ParticleTypes.size() == (size_t)getParticleTypeNumber(),
    7575        "generateBindingModel() - PairPotential_Harmonic needs two types.");
    7676    nodes.push_back( FragmentNode(_ParticleTypes[0], 1) );
  • src/Potentials/Specifics/PairPotential_Harmonic.hpp

    re83114 ra0d8aa  
    5151  PairPotential_Harmonic();
    5252
     53  /** Creates the binding model specific for this potential.
     54   *
     55   * Private because this is used internally some of the constructors.
     56   *
     57   * \param _ParticleTypes particle type for the potential
     58   * \return binding model
     59   */
     60  BindingModel generateBindingModel(const EmpiricalPotential::ParticleTypes_t &_ParticleTypes) const;
     61
    5362public:
    5463  PairPotential_Harmonic(const ParticleTypes_t &_ParticleTypes);
  • src/Potentials/Specifics/PairPotential_LennardJones.cpp

    re83114 ra0d8aa  
    6767Coordinator::ptr PairPotential_LennardJones::coordinator( /* Memory::ignore( */ new TwoBody_Length() /* ) */ );
    6868
    69 static BindingModel generateBindingModel(const EmpiricalPotential::ParticleTypes_t &_ParticleTypes)
     69BindingModel PairPotential_LennardJones::generateBindingModel(const EmpiricalPotential::ParticleTypes_t &_ParticleTypes) const
    7070{
    7171  // fill nodes
    7272  BindingModel::vector_nodes_t nodes;
    7373  {
    74     ASSERT( _ParticleTypes.size() == (size_t)2,
     74    ASSERT( _ParticleTypes.size() == (size_t)getParticleTypeNumber(),
    7575        "generateBindingModel() - PairPotential_LennardJones needs two types.");
    7676    nodes.push_back( FragmentNode(_ParticleTypes[0], 1) );
  • src/Potentials/Specifics/PairPotential_LennardJones.hpp

    re83114 ra0d8aa  
    5252  PairPotential_LennardJones();
    5353
     54  /** Creates the binding model specific for this potential.
     55   *
     56   * Private because this is used internally some of the constructors.
     57   *
     58   * \param _ParticleTypes particle type for the potential
     59   * \return binding model
     60   */
     61  BindingModel generateBindingModel(const EmpiricalPotential::ParticleTypes_t &_ParticleTypes) const;
     62
    5463public:
    5564  PairPotential_LennardJones(const ParticleTypes_t &_ParticleTypes);
  • src/Potentials/Specifics/PairPotential_Morse.cpp

    re83114 ra0d8aa  
    6969Coordinator::ptr PairPotential_Morse::coordinator( /* Memory::ignore( */ new TwoBody_Length() /* ) */ );
    7070
    71 static BindingModel generateBindingModel(const EmpiricalPotential::ParticleTypes_t &_ParticleTypes)
     71BindingModel PairPotential_Morse::generateBindingModel(const EmpiricalPotential::ParticleTypes_t &_ParticleTypes) const
    7272{
    7373  // fill nodes
    7474  BindingModel::vector_nodes_t nodes;
    7575  {
    76     ASSERT( _ParticleTypes.size() == (size_t)2,
     76    ASSERT( _ParticleTypes.size() == (size_t)getParticleTypeNumber(),
    7777        "generateBindingModel() - PairPotential_Morse needs two types.");
    7878    nodes.push_back( FragmentNode(_ParticleTypes[0], 1) );
  • src/Potentials/Specifics/PairPotential_Morse.hpp

    re83114 ra0d8aa  
    5151  PairPotential_Morse();
    5252
     53  /** Creates the binding model specific for this potential.
     54   *
     55   * Private because this is used internally some of the constructors.
     56   *
     57   * \param _ParticleTypes particle type for the potential
     58   * \return binding model
     59   */
     60  BindingModel generateBindingModel(const EmpiricalPotential::ParticleTypes_t &_ParticleTypes) const;
     61
    5362public:
    5463  PairPotential_Morse(const ParticleTypes_t &_ParticleTypes);
  • src/Potentials/Specifics/ThreeBodyPotential_Angle.cpp

    re83114 ra0d8aa  
    6767Coordinator::ptr ThreeBodyPotential_Angle::coordinator( /* Memory::ignore( */ new ThreeBody_Angle() /* ) */ );
    6868
    69 static BindingModel generateBindingModel(const EmpiricalPotential::ParticleTypes_t &_ParticleTypes)
     69BindingModel ThreeBodyPotential_Angle::generateBindingModel(const EmpiricalPotential::ParticleTypes_t &_ParticleTypes) const
    7070{
    7171  // fill nodes
    7272  BindingModel::vector_nodes_t nodes;
    7373  {
    74     ASSERT( _ParticleTypes.size() == (size_t)3,
     74    ASSERT( _ParticleTypes.size() == (size_t)getParticleTypeNumber(),
    7575        "generateBindingModel() - ThreeBodyPotential_Angle needs three types.");
    7676    nodes.push_back( FragmentNode(_ParticleTypes[0], 1) );
  • src/Potentials/Specifics/ThreeBodyPotential_Angle.hpp

    re83114 ra0d8aa  
    5151  ThreeBodyPotential_Angle();
    5252
     53  /** Creates the binding model specific for this potential.
     54   *
     55   * Private because this is used internally some of the constructors.
     56   *
     57   * \param _ParticleTypes particle type for the potential
     58   * \return binding model
     59   */
     60  BindingModel generateBindingModel(const EmpiricalPotential::ParticleTypes_t &_ParticleTypes) const;
     61
    5362public:
    5463  ThreeBodyPotential_Angle(const ParticleTypes_t &_ParticleTypes);
Note: See TracChangeset for help on using the changeset viewer.