Ignore:
Timestamp:
Aug 30, 2025, 2:41:40 PM (8 weeks ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
Candidate_v1.7.0, stable
Children:
a0d8aa
Parents:
72b6d7
git-author:
Frederik Heber <frederik.heber@…> (08/16/25 10:32:39)
git-committer:
Frederik Heber <frederik.heber@…> (08/30/25 14:41:40)
Message:

StreamFactory_EmpiricalPotential creates potential instances with params.

  • EmpiricalPotential expose getter and setter for parameters.
  • potential and stream factor for EmpiricalPotential have new createInstance that also takes a present parameter set.
  • this is used in StreamFactory_EmpiricalPotential::createInstance from istream to create the correct instance with parameters directly.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Potentials/PotentialFactory.cpp

    r72b6d7 re83114  
    137137}
    138138
    139 EmpiricalPotential* PotentialFactory::getDefaultPotential(const std::string &_name) const
    140 {
    141   EmpiricalPotential *potential = NULL;
    142   switch (getTypeForName(_name)) {
     139EmpiricalPotential *PotentialFactory::createInstance(
     140    const std::string &potentialtype,
     141    const SerializablePotential::ParticleTypes_t &types,
     142                const FunctionModel::parameters_t &params) const
     143{
     144        EmpiricalPotential *potential = NULL;
     145  switch (getTypeForName(potentialtype)) {
    143146  case constant:
    144     potential = new ConstantPotential();
    145     break;
     147      potential = new ConstantPotential(types);
     148      break;
    146149  case tersoff:
    147     potential = new ManyBodyPotential_Tersoff();
    148     break;
     150      potential = new ManyBodyPotential_Tersoff(types);
     151      break;
    149152  case morse:
    150     potential = new PairPotential_Morse();
    151     break;
     153      potential = new PairPotential_Morse(types);
     154      break;
    152155  case harmonic_bond:
    153     potential = new PairPotential_Harmonic();
    154     break;
     156      potential = new PairPotential_Harmonic(types);
     157      break;
    155158  case harmonic_angle:
    156     potential = new ThreeBodyPotential_Angle();
    157     break;
     159      potential = new ThreeBodyPotential_Angle(types);
     160      break;
    158161  case lennardjones:
    159     potential = new PairPotential_LennardJones();
    160     break;
     162      potential = new PairPotential_LennardJones(types);
     163      break;
    161164  case torsion:
    162     potential = new FourBodyPotential_Torsion();
    163     break;
     165      potential = new FourBodyPotential_Torsion(types);
     166      break;
    164167  case improper:
    165     potential = new FourBodyPotential_Improper();
    166     break;
     168      potential = new FourBodyPotential_Improper(types);
     169      break;
    167170  default:
    168171    ASSERT(0, "PotentialFactory::createInstance() - unknown potential desired to create.");
    169172    break;
    170173  }
     174  if (potential != NULL)
     175        potential->setParameters(params);
    171176  return potential;
     177}
     178
     179EmpiricalPotential* PotentialFactory::getDefaultPotential(const std::string &_name) const
     180{
     181  switch (getTypeForName(_name)) {
     182  case constant:
     183    return new ConstantPotential();
     184  case tersoff:
     185    return new ManyBodyPotential_Tersoff();
     186  case morse:
     187    return new PairPotential_Morse();
     188  case harmonic_bond:
     189    return new PairPotential_Harmonic();
     190  case harmonic_angle:
     191    return new ThreeBodyPotential_Angle();
     192  case lennardjones:
     193    return new PairPotential_LennardJones();
     194  case torsion:
     195    return new FourBodyPotential_Torsion();
     196  case improper:
     197    return new FourBodyPotential_Improper();
     198  default:
     199    ASSERT(0, "PotentialFactory::createInstance() - unknown potential desired to create.");
     200    break;
     201  }
     202  return NULL;
    172203}
    173204
Note: See TracChangeset for help on using the changeset viewer.