Changes in / [9e1bfb:2ed3bf]


Ignore:
Files:
11 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • doc/userguide/userguide.xml

    r9e1bfb r2ed3bf  
    21232123            a fragment of order 1, e.g. a single hydrogen atom.</para>
    21242124          </note>
    2125         </section>
    2126 
    2127         <section xml:id='potentials.fit-compound-potential'>
    2128           <title xml:id='potentials.fit-compound-potential.title'>Fitting
    2129           many empirical potentials simultaneously</title>
    2130 
    21312125
    21322126          <para>Another way is using a file containing a specific set of
     
    21342128
    21352129          <programlisting>
    2136                 ... --fit-compound-potential \
     2130                ... --fit-potential \
    21372131                    --fragment-charges 8 1 1 \
    21382132                    --potential-file water.potentials \
     
    21562150          type of analysis.</para>
    21572151
    2158           <para>Note that you can combine the two ways, i.e. start with a
    2159           fit-potential call but give an empty potential file. The resulting
    2160           parameters are stored in it. Fit other potentials and give different
    2161           file names for each in turn. Eventually, you have to combine the file
    2162           in a text editor at the moment. And perform a fit-compound-potential
    2163           with this file.</para>
    2164         </section>
    2165 
    2166        
    2167         <section xml:id='potentials.parse-potential'>
    2168           <title xml:id='potentials.parse-potential.title'>Parsing an
    2169           empirical potentials file</title>
    2170 
    2171           <para>Responsible for the compound potential is every potential
    2172           function whose signature matches with the designated fragment-charges
    2173           and who is currently known to an internal instance called the
    2174           PotentialRegistry.</para>
    2175 
    2176           <para>More potentials can be registered (fit-potential will also
    2177           register the potential it fits) by parsing them from a file.</para>
    2178 
    2179           <programlisting>
    2180                 ... --parse-potentials water.potentials
    2181           </programlisting>
    2182 
    2183           <note>Currently, only <productname>TREMOLO</productname> potential
    2184           files are understood and can be parsed.</note>
    2185         </section>
    2186 
    2187         <section xml:id='potentials.save-potential'>
    2188           <title xml:id='potentials.save-potential.title'>Saving an
    2189           empirical potentials file</title>
    2190 
    2191           <para>The opposite to parse-potentials is save-potentials that writes
    2192           every potential currently known to the PotentialRegistry to the given
    2193           file along with the currently fitted parameters</para>
    2194 
    2195           <programlisting>
    2196                 ... --save-potentials water.potentials
    2197           </programlisting>
    2198 
    2199           <note>Again, only the <productname>TREMOLO</productname> potential
    2200           format is understood currently and is written.</note>
     2152          <para>Note that you can combine the two ways, i.e. start with the
     2153          first but give an empty potential file. The resulting parameters are
     2154          stored in this way. Fit other potentials and give different file
     2155          names for each. Eventually, you have to combine the file in a text
     2156          editor at the moment.</para>
    22012157        </section>
    22022158
  • src/Actions/GlobalListOfActions.hpp

    r9e1bfb r2ed3bf  
    8484  (PotentialFitParticleCharges) \
    8585  (PotentialParseHomologies) \
    86   (PotentialParsePotentials) \
    8786  (PotentialSaveHomologies) \
    88   (PotentialSavePotentials) \
    8987  (ParserParseTremoloPotentials) \
    9088  (ParserSaveSelectedAtomsAsExtTypes) \
     
    151149#define GLOBALLISTOFACTIONS_LEVMAR \
    152150    BOOST_PP_SEQ_PUSH_BACK( \
    153                 BOOST_PP_SEQ_PUSH_BACK( \
    154                                 GLOBALLISTOFACTIONS_initial, \
    155                                 PotentialFitPotential \
    156                 ), \
    157         PotentialFitCompoundPotential \
     151        GLOBALLISTOFACTIONS_initial, \
     152        PotentialFitPotential \
    158153    )
    159154#else
  • src/Actions/Makefile.am

    r9e1bfb r2ed3bf  
    354354  Actions/PotentialAction/FitParticleChargesAction.cpp \
    355355  Actions/PotentialAction/ParseHomologiesAction.cpp \
    356   Actions/PotentialAction/ParsePotentialsAction.cpp \
    357   Actions/PotentialAction/SaveHomologiesAction.cpp \
    358   Actions/PotentialAction/SavePotentialsAction.cpp
     356  Actions/PotentialAction/SaveHomologiesAction.cpp
    359357POTENTIALACTIONHEADER = \
    360358  Actions/PotentialAction/FitParticleChargesAction.hpp \
    361359  Actions/PotentialAction/ParseHomologiesAction.hpp \
    362   Actions/PotentialAction/ParsePotentialsAction.hpp \
    363   Actions/PotentialAction/SaveHomologiesAction.hpp \
    364   Actions/PotentialAction/SavePotentialsAction.hpp
     360  Actions/PotentialAction/SaveHomologiesAction.hpp
    365361POTENTIALACTIONDEFS = \
    366362  Actions/PotentialAction/FitParticleChargesAction.def  \
    367363  Actions/PotentialAction/ParseHomologiesAction.def \
    368   Actions/PotentialAction/ParsePotentialsAction.def \
    369   Actions/PotentialAction/SaveHomologiesAction.def \
    370   Actions/PotentialAction/SavePotentialsAction.def
     364  Actions/PotentialAction/SaveHomologiesAction.def
    371365
    372366if CONDLEVMAR
    373367POTENTIALACTIONSOURCE += \
    374   Actions/PotentialAction/FitCompoundPotentialAction.cpp \
    375368  Actions/PotentialAction/FitPotentialAction.cpp
    376369POTENTIALACTIONHEADER += \
    377   Actions/PotentialAction/FitCompoundPotentialAction.hpp \
    378370  Actions/PotentialAction/FitPotentialAction.hpp
    379371POTENTIALACTIONDEFS += \
    380   Actions/PotentialAction/FitCompoundPotentialAction.def \
    381372  Actions/PotentialAction/FitPotentialAction.def
    382373endif
  • src/Actions/PotentialAction/FitPotentialAction.cpp

    r9e1bfb r2ed3bf  
    5555#include "Fragmentation/Homology/HomologyGraph.hpp"
    5656#include "Fragmentation/Summation/SetValues/Fragment.hpp"
    57 #include "Potentials/EmpiricalPotential.hpp"
     57#include "FunctionApproximation/Extractors.hpp"
     58#include "FunctionApproximation/FunctionApproximation.hpp"
     59#include "FunctionApproximation/FunctionModel.hpp"
     60#include "FunctionApproximation/TrainingData.hpp"
     61#include "FunctionApproximation/writeDistanceEnergyTable.hpp"
     62#include "Potentials/CompoundPotential.hpp"
     63#include "Potentials/Exceptions.hpp"
     64#include "Potentials/PotentialDeserializer.hpp"
    5865#include "Potentials/PotentialFactory.hpp"
    5966#include "Potentials/PotentialRegistry.hpp"
    6067#include "Potentials/PotentialSerializer.hpp"
    61 #include "Potentials/PotentialTrainer.hpp"
    6268#include "Potentials/SerializablePotential.hpp"
    63 #include "World.hpp"
    6469
    6570using namespace MoleCuilder;
     
    7075/** =========== define the function ====================== */
    7176
     77HomologyGraph getFirstGraphwithSpecifiedElements(
     78    const HomologyContainer &homologies,
     79    const SerializablePotential::ParticleTypes_t &types)
     80{
     81  ASSERT( !types.empty(),
     82      "getFirstGraphwithSpecifiedElements() - charges is empty?");
     83  // create charges
     84  Fragment::charges_t charges;
     85  charges.resize(types.size());
     86  std::transform(types.begin(), types.end(),
     87      charges.begin(), boost::lambda::_1);
     88  // convert into count map
     89  Extractors::elementcounts_t counts_per_charge =
     90      Extractors::_detail::getElementCounts(charges);
     91  ASSERT( !counts_per_charge.empty(),
     92      "getFirstGraphwithSpecifiedElements() - charge counts are empty?");
     93  LOG(2, "DEBUG: counts_per_charge is " << counts_per_charge << ".");
     94  // we want to check each (unique) key only once
     95  for (HomologyContainer::const_key_iterator iter = homologies.key_begin();
     96      iter != homologies.key_end(); iter = homologies.getNextKey(iter)) {
     97    // check if every element has the right number of counts
     98    Extractors::elementcounts_t::const_iterator countiter = counts_per_charge.begin();
     99    for (; countiter != counts_per_charge.end(); ++countiter)
     100      if (!(*iter).hasTimesAtomicNumber(
     101          static_cast<size_t>(countiter->first),
     102          static_cast<size_t>(countiter->second))
     103          )
     104        break;
     105    if( countiter == counts_per_charge.end())
     106      return *iter;
     107  }
     108  return HomologyGraph();
     109}
     110
     111SerializablePotential::ParticleTypes_t getNumbersFromElements(
     112    const std::vector<const element *> &fragment)
     113{
     114  SerializablePotential::ParticleTypes_t fragmentnumbers;
     115  std::transform(fragment.begin(), fragment.end(), std::back_inserter(fragmentnumbers),
     116      boost::bind(&element::getAtomicNumber, _1));
     117  return fragmentnumbers;
     118}
     119
     120
    72121ActionState::ptr PotentialFitPotentialAction::performCall() {
    73122  // fragment specifies the homology fragment to use
    74123  SerializablePotential::ParticleTypes_t fragmentnumbers =
    75       PotentialTrainer::getNumbersFromElements(params.fragment.get());
     124      getNumbersFromElements(params.fragment.get());
    76125
    77126  // either charges and a potential is specified or a file
    78   if (params.charges.get().empty()) {
    79     STATUS("No charges given!");
    80     return Action::failure;
     127  if (boost::filesystem::exists(params.potential_file.get())) {
     128    std::ifstream returnstream(params.potential_file.get().string().c_str());
     129    if (returnstream.good()) {
     130      try {
     131        PotentialDeserializer deserialize(returnstream);
     132        deserialize();
     133      } catch (SerializablePotentialMissingValueException &e) {
     134        if (const std::string *key = boost::get_error_info<SerializablePotentialKey>(e))
     135          STATUS("Missing value when parsing information for potential "+*key+".");
     136        else
     137          STATUS("Missing value parsing information for potential with unknown key.");
     138        return Action::failure;
     139      } catch (SerializablePotentialIllegalKeyException &e) {
     140        if (const std::string *key = boost::get_error_info<SerializablePotentialKey>(e))
     141          STATUS("Illegal key parsing information for potential "+*key+".");
     142        else
     143          STATUS("Illegal key parsing information for potential with unknown key.");
     144        return Action::failure;
     145      }
     146    } else {
     147      STATUS("Failed to parse from "+params.potential_file.get().string()+".");
     148      return Action::failure;
     149    }
     150    returnstream.close();
     151
     152    LOG(0, "STATUS: I'm training now a set of potentials parsed from "
     153        << params.potential_file.get().string() << " on a fragment "
     154        << fragmentnumbers << " on data from World's homologies.");
     155
    81156  } else {
    82     // charges specify the potential type
    83     SerializablePotential::ParticleTypes_t chargenumbers =
    84         PotentialTrainer::getNumbersFromElements(params.charges.get());
    85 
    86     LOG(0, "STATUS: I'm training now a " << params.potentialtype.get()
    87         << " potential on charges " << chargenumbers << " on data from World's homologies.");
    88 
    89     // register desired potential and an additional constant one
    90     {
    91       EmpiricalPotential *potential =
    92           PotentialFactory::getInstance().createInstance(
    93               params.potentialtype.get(),
    94               chargenumbers);
    95       // check whether such a potential already exists
    96       const std::string potential_name = potential->getName();
    97       if (PotentialRegistry::getInstance().isPresentByName(potential_name)) {
    98         delete potential;
    99         potential = PotentialRegistry::getInstance().getByName(potential_name);
    100       } else
    101         PotentialRegistry::getInstance().registerInstance(potential);
    102     }
    103     {
    104       EmpiricalPotential *constant =
    105           PotentialFactory::getInstance().createInstance(
    106               std::string("constant"),
    107               SerializablePotential::ParticleTypes_t());
    108       // check whether such a potential already exists
    109       const std::string constant_name = constant->getName();
    110       if (PotentialRegistry::getInstance().isPresentByName(constant_name)) {
    111         delete constant;
    112         constant = PotentialRegistry::getInstance().getByName(constant_name);
    113       } else
    114         PotentialRegistry::getInstance().registerInstance(constant);
     157    if (params.charges.get().empty()) {
     158      STATUS("Neither charges nor potential file given!");
     159      return Action::failure;
     160    } else {
     161      // charges specify the potential type
     162      SerializablePotential::ParticleTypes_t chargenumbers =
     163          getNumbersFromElements(params.charges.get());
     164
     165      LOG(0, "STATUS: I'm training now a " << params.potentialtype.get()
     166          << " potential on charges " << chargenumbers << " on data from World's homologies.");
     167
     168      // register desired potential and an additional constant one
     169      {
     170        EmpiricalPotential *potential =
     171            PotentialFactory::getInstance().createInstance(
     172                params.potentialtype.get(),
     173                chargenumbers);
     174        // check whether such a potential already exists
     175        const std::string potential_name = potential->getName();
     176        if (PotentialRegistry::getInstance().isPresentByName(potential_name)) {
     177          delete potential;
     178          potential = PotentialRegistry::getInstance().getByName(potential_name);
     179        } else
     180          PotentialRegistry::getInstance().registerInstance(potential);
     181      }
     182      {
     183        EmpiricalPotential *constant =
     184            PotentialFactory::getInstance().createInstance(
     185                std::string("constant"),
     186                SerializablePotential::ParticleTypes_t());
     187        // check whether such a potential already exists
     188        const std::string constant_name = constant->getName();
     189        if (PotentialRegistry::getInstance().isPresentByName(constant_name)) {
     190          delete constant;
     191          constant = PotentialRegistry::getInstance().getByName(constant_name);
     192        } else
     193          PotentialRegistry::getInstance().registerInstance(constant);
     194      }
    115195    }
    116196  }
    117197
    118198  // parse homologies into container
    119   const HomologyContainer &homologies = World::getInstance().getHomologies();
     199  HomologyContainer &homologies = World::getInstance().getHomologies();
    120200
    121201  // first we try to look into the HomologyContainer
     
    131211
    132212  // then we ought to pick the right HomologyGraph ...
    133   const HomologyGraph graph =
    134       PotentialTrainer::getFirstGraphwithSpecifiedElements(homologies,fragmentnumbers);
     213  const HomologyGraph graph = getFirstGraphwithSpecifiedElements(homologies,fragmentnumbers);
    135214  if (graph != HomologyGraph()) {
    136215    LOG(1, "First representative graph containing fragment "
     
    141220  }
    142221
    143   // training
    144   PotentialTrainer trainer;
    145   const bool status = trainer(
    146       homologies,
    147       graph,
    148       params.training_file.get(),
    149       params.threshold.get(),
    150       params.best_of_howmany.get());
    151   if (!status) {
    152     STATUS("No required parameter derivatives for a box constraint minimization known.");
    153     return Action::failure;
    154   }
     222  // fit potential
     223  FunctionModel *model = new CompoundPotential(graph);
     224  ASSERT( model != NULL,
     225      "PotentialFitPotentialAction::performCall() - model is NULL.");
     226
     227  /******************** TRAINING ********************/
     228  // fit potential
     229  FunctionModel::parameters_t bestparams(model->getParameterDimension(), 0.);
     230  {
     231    // Afterwards we go through all of this type and gather the distance and the energy value
     232    TrainingData data(model->getSpecificFilter());
     233    data(homologies.getHomologousGraphs(graph));
     234
     235    // print distances and energies if desired for debugging
     236    if (!data.getTrainingInputs().empty()) {
     237      // print which distance is which
     238      size_t counter=1;
     239      if (DoLog(3)) {
     240        const FunctionModel::arguments_t &inputs = data.getAllArguments()[0];
     241        for (FunctionModel::arguments_t::const_iterator iter = inputs.begin();
     242            iter != inputs.end(); ++iter) {
     243          const argument_t &arg = *iter;
     244          LOG(3, "DEBUG: distance " << counter++ << " is between (#"
     245              << arg.indices.first << "c" << arg.types.first << ","
     246              << arg.indices.second << "c" << arg.types.second << ").");
     247        }
     248      }
     249
     250      // print table
     251      if (params.training_file.get().string().empty()) {
     252        LOG(3, "DEBUG: I gathered the following training data:\n" <<
     253            _detail::writeDistanceEnergyTable(data.getDistanceEnergyTable()));
     254      } else {
     255        std::ofstream trainingstream(params.training_file.get().string().c_str());
     256        if (trainingstream.good()) {
     257          LOG(3, "DEBUG: Writing training data to file " <<
     258              params.training_file.get().string() << ".");
     259          trainingstream << _detail::writeDistanceEnergyTable(data.getDistanceEnergyTable());
     260        }
     261        trainingstream.close();
     262      }
     263    }
     264
     265    if ((params.threshold.get() < 1) && (params.best_of_howmany.isSet()))
     266      ELOG(2, "threshold parameter always overrules max_runs, both are specified.");
     267    // now perform the function approximation by optimizing the model function
     268    FunctionApproximation approximator(data, *model);
     269    if (model->isBoxConstraint() && approximator.checkParameterDerivatives()) {
     270      double l2error = std::numeric_limits<double>::max();
     271      // seed with current time
     272      srand((unsigned)time(0));
     273      unsigned int runs=0;
     274      // threshold overrules max_runs
     275      const double threshold = params.threshold.get();
     276      const unsigned int max_runs = (threshold >= 1.) ?
     277          (params.best_of_howmany.isSet() ? params.best_of_howmany.get() : 1) : 0;
     278      LOG(1, "INFO: Maximum runs is " << max_runs << " and threshold set to " << threshold << ".");
     279      do {
     280        // generate new random initial parameter values
     281        model->setParametersToRandomInitialValues(data);
     282        LOG(1, "INFO: Initial parameters of run " << runs << " are "
     283            << model->getParameters() << ".");
     284        approximator(FunctionApproximation::ParameterDerivative);
     285        LOG(1, "INFO: Final parameters of run " << runs << " are "
     286            << model->getParameters() << ".");
     287        const double new_l2error = data.getL2Error(*model);
     288        if (new_l2error < l2error) {
     289          // store currently best parameters
     290          l2error = new_l2error;
     291          bestparams = model->getParameters();
     292          LOG(1, "STATUS: New fit from run " << runs
     293              << " has better error of " << l2error << ".");
     294        }
     295      } while (( ++runs < max_runs) || (l2error > threshold));
     296      // reset parameters from best fit
     297      model->setParameters(bestparams);
     298      LOG(1, "INFO: Best parameters with L2 error of "
     299          << l2error << " are " << model->getParameters() << ".");
     300    } else {
     301      STATUS("No required parameter derivatives for a box constraint minimization known.");
     302      return Action::failure;
     303    }
     304
     305    // create a map of each fragment with error.
     306    HomologyContainer::range_t fragmentrange = homologies.getHomologousGraphs(graph);
     307    TrainingData::L2ErrorConfigurationIndexMap_t WorseFragmentMap =
     308        data.getWorstFragmentMap(*model, fragmentrange);
     309    LOG(0, "RESULT: WorstFragmentMap " << WorseFragmentMap << ".");
     310
     311    // print fitted potentials
     312    std::stringstream potentials;
     313    PotentialSerializer serialize(potentials);
     314    serialize();
     315    LOG(1, "STATUS: Resulting parameters are " << std::endl << potentials.str());
     316    std::ofstream returnstream(params.potential_file.get().string().c_str());
     317    if (returnstream.good()) {
     318      returnstream << potentials.str();
     319    }
     320  }
     321  delete model;
    155322
    156323  return Action::success;
  • src/Actions/PotentialAction/FitPotentialAction.def

    r9e1bfb r2ed3bf  
    1818#include "Parameters/Validators/Specific/ElementValidator.hpp"
    1919#include "Parameters/Validators/Specific/EmptyStringValidator.hpp"
     20#include "Parameters/Validators/Specific/FileSuffixValidator.hpp"
     21#include "Parameters/Validators/Specific/FilePresentValidator.hpp"
    2022#include "Parameters/Validators/Specific/PotentialTypeValidator.hpp"
    2123
     
    2325// ValueStorage by the token "Z" -> first column: int, Z, "Z"
    2426// "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value
    25 #define paramtypes (boost::filesystem::path)(std::string)(std::vector<const element *>)(std::vector<const element *>)(unsigned int)(double)
    26 #define paramtokens ("training-file")("potential-type")("potential-charges")("fragment-charges")("take-best-of")("set-threshold")
    27 #define paramdescriptions ("optional file to write training data to")("potential type to fit")("charges specifying the potential")("charges specifying the fragment")("take the best among this many approximations")("Require L2 error to be smaller than threshold, overrides number of attempts")
    28 #define paramdefaults (PARAM_DEFAULT(""))(NOPARAM_DEFAULT)(NOPARAM_DEFAULT)(NOPARAM_DEFAULT)(PARAM_DEFAULT(3))(PARAM_DEFAULT(1.))
    29 #define paramreferences (training_file)(potentialtype)(charges)(fragment)(best_of_howmany)(threshold)
     27#define paramtypes (boost::filesystem::path)(std::string)(boost::filesystem::path)(std::vector<const element *>)(std::vector<const element *>)(unsigned int)(double)
     28#define paramtokens ("training-file")("potential-type")("potential-file")("potential-charges")("fragment-charges")("take-best-of")("set-threshold")
     29#define paramdescriptions ("optional file to write training data to")("potential type to fit")("optional potential file specifying multiple potentials to fit")("charges specifying the potential")("charges specifying the fragment")("take the best among this many approximations")("Require L2 error to be smaller than threshold, overrides number of attempts")
     30#define paramdefaults (PARAM_DEFAULT(""))(NOPARAM_DEFAULT)(NOPARAM_DEFAULT)(NOPARAM_DEFAULT)(NOPARAM_DEFAULT)(PARAM_DEFAULT(3))(PARAM_DEFAULT(1.))
     31#define paramreferences (training_file)(potentialtype)(potential_file)(charges)(fragment)(best_of_howmany)(threshold)
    3032#define paramvalids \
    3133(DummyValidator<boost::filesystem::path>()) \
    32 (PotentialTypeValidator()) \
     34(EmptyStringValidator() || PotentialTypeValidator()) \
     35(!FilePresentValidator() || FileSuffixValidator("potentials")) \
    3336(STLVectorValidator< std::vector<const element *> >(0,99, ElementValidator())) \
    3437(STLVectorValidator< std::vector<const element *> >(1,99, ElementValidator())) \
  • src/Potentials/Makefile.am

    r9e1bfb r2ed3bf  
    5353  Potentials/Specifics/PotentialTypes.def \
    5454  Potentials/Specifics/PotentialTypes.undef
    55 
    56 if CONDLEVMAR
    57 POTENTIALSHEADER += \
    58   Potentials/PotentialTrainer.hpp
    59 POTENTIALSSOURCE = \
    60   Potentials/PotentialTrainer.cpp
    61 endif
    6255
    6356# add here headers for real potentials (i.e. the PotentialFactory should instantiate) 
  • tests/Python/AllActions/options.dat

    r9e1bfb r2ed3bf  
    125125output-types    "xyz mpqc"
    126126parse-homologies        "homology.dat"
    127 parse-potentials        "water.potentials"
    128127parse-tremolo-potentials        "argon.potentials"
    129128parse-tremolo-potentials        "tensid.potentials"
     
    164163save-bonds      "test.bond"
    165164save-homologies "homology.dat"
    166 save-potentials "water.potentials"
    167165save-selected-atoms     "testsave.xyz"
    168166save-selected-atoms-as-exttypes "test.exttypes"
  • tests/regression/Potential/FitPotential/testsuite-potential-fit-potential.at

    r9e1bfb r2ed3bf  
    2626AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Potential/FitPotential/pre/$file $file], 0)
    2727AT_CHECK([chmod u+w $file], 0, [ignore], [ignore])
    28 AT_CHECK([../../molecuilder \
    29         --parse-homologies $file \
    30         --set-random-number-engine "lagged_fibonacci607" \
    31                 --random-number-engine-parameters "seed=1;" \
    32         --set-random-number-distribution "uniform_real" \
    33                 --random-number-distribution-parameters "min=0;max=1;" \
    34         --fit-potential \
    35                 --potential-type "morse" \
    36                 --potential-charges 8 1 \
    37                 --fragment-charges 1 8 1 \
    38                 --set-threshold 1e-6 \
    39         --save-potentials length.potentials], 0, [stdout], [ignore])
     28AT_CHECK([../../molecuilder --parse-homologies $file --set-random-number-engine "lagged_fibonacci607" --random-number-engine-parameters "seed=1;" --set-random-number-distribution "uniform_real" --random-number-distribution-parameters "min=0;max=1;" --fit-potential --potential-type "morse" --potential-charges 8 1 --fragment-charges 1 8 1 --set-threshold 1e-6], 0, [stdout], [ignore])
    4029# check that L_2 error is below 1e-6
    4130AT_CHECK([grep "Best parameters with L2 error" stdout | awk '{if ($8 > 1e-6) exit 1}'], 0, [ignore], [ignore])
    4231# check parameters to printed precision
    43 AT_CHECK([grep "morse:.*particle_type1=8,.*particle_type2=1,.*spring_constant=1.27.*,.*equilibrium_distance=1.78.*,.*dissociation_energy=0.19.*;" length.potentials], 0, [ignore], [ignore])
     32AT_CHECK([grep "morse:.*particle_type1=8,.*particle_type2=1,.*spring_constant=1.27.*,.*equilibrium_distance=1.78.*,.*dissociation_energy=0.19.*;" stdout], 0, [ignore], [ignore])
    4433
    4534AT_CLEANUP
     
    5241AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Potential/FitPotential/pre/$file $file], 0)
    5342AT_CHECK([chmod u+w $file], 0, [ignore], [ignore])
    54 AT_CHECK([../../molecuilder \
    55         --parse-homologies $file \
    56         --set-random-number-engine "lagged_fibonacci607" \
    57                 --random-number-engine-parameters "seed=1;" \
    58         --set-random-number-distribution "uniform_real" \
    59                 --random-number-distribution-parameters "min=0;max=1;" \
    60         --fit-potential \
    61                 --potential-type "harmonic_bond" \
    62                 --potential-charges 8 1 \
    63                 --fragment-charges 1 8 1 \
    64                 --set-threshold 1e-6 \
    65         --save-potentials harmonic.potentials], 0, [stdout], [ignore])
     43AT_CHECK([../../molecuilder --parse-homologies $file --set-random-number-engine "lagged_fibonacci607" --random-number-engine-parameters "seed=1;" --set-random-number-distribution "uniform_real" --random-number-distribution-parameters "min=0;max=1;" --fit-potential --potential-type "harmonic_bond" --potential-charges 8 1 --fragment-charges 1 8 1 --set-threshold 1e-6], 0, [stdout], [ignore])
    6644# check that L_2 error is below 1e-6
    6745AT_CHECK([grep "Best parameters with L2 error" stdout | awk '{if ($8 > 1e-6) exit 1}'], 0, [ignore], [ignore])
    6846# check parameters to printed precision
    69 AT_CHECK([grep "harmonic_bond:.*particle_type1=8,.*particle_type2=1,.*spring_constant=0.29.*,.*equilibrium_distance=1.8.*;" harmonic.potentials], 0, [ignore], [ignore])
     47AT_CHECK([grep "harmonic_bond:.*particle_type1=8,.*particle_type2=1,.*spring_constant=0.29.*,.*equilibrium_distance=1.8.*;" stdout], 0, [ignore], [ignore])
    7048
    7149AT_CLEANUP
     
    7856AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Potential/FitPotential/pre/$file $file], 0)
    7957AT_CHECK([chmod u+w $file], 0, [ignore], [ignore])
    80 AT_CHECK([../../molecuilder \
    81         --parse-homologies $file \
    82         --set-random-number-engine "lagged_fibonacci607" \
    83                 --random-number-engine-parameters "seed=1;" \
    84         --set-random-number-distribution "uniform_real" \
    85                 --random-number-distribution-parameters "min=0;max=1;" \
    86         --fit-potential \
    87                 --potential-type "harmonic_angle" \
    88                 --potential-charges 1 8 1 \
    89                 --fragment-charges 1 8 1 \
    90                 --set-threshold 1e-6 \
    91         --save-potentials angle.potentials], 0, [stdout], [ignore])
     58AT_CHECK([../../molecuilder --parse-homologies $file --set-random-number-engine "lagged_fibonacci607" --random-number-engine-parameters "seed=1;" --set-random-number-distribution "uniform_real" --random-number-distribution-parameters "min=0;max=1;" --fit-potential --potential-type "harmonic_angle" --potential-charges 1 8 1 --fragment-charges 1 8 1 --set-threshold 1e-6], 0, [stdout], [ignore])
    9259# check that L_2 error is below 1e-6
    9360AT_CHECK([grep "||e||_2:" stdout | awk '{if ($7 > 1e-6) exit 1}'], 0, [ignore], [ignore])
    9461# check parameters to printed precision
    95 AT_CHECK([grep "harmonic_angle:.*particle_type1=1,.*particle_type2=8,.*particle_type3=1,.*spring_constant=0.10.*,.*equilibrium_distance=-0.27.*;" angle.potentials], 0, [ignore], [ignore])
     62AT_CHECK([grep "harmonic_angle:.*particle_type1=1,.*particle_type2=8,.*particle_type3=1,.*spring_constant=0.10.*,.*equilibrium_distance=-0.27.*;" stdout], 0, [ignore], [ignore])
    9663
    9764AT_CLEANUP
     
    10471AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Potential/FitPotential/pre/$file $file], 0)
    10572AT_CHECK([chmod u+w $file], 0, [ignore], [ignore])
    106 AT_CHECK([../../molecuilder \
    107         --parse-homologies $file \
    108         --set-random-number-engine "lagged_fibonacci607" \
    109                 --random-number-engine-parameters "seed=1;" \
    110         --set-random-number-distribution "uniform_real" \
    111                 --random-number-distribution-parameters "min=0;max=1;" \
    112         --fit-potential \
    113                 --potential-type "torsion" \
    114                 --potential-charges 6 6 6 6 \
    115                 --fragment-charges 6 6 6 6 1 1 1 1 1 1 1 1 1 1 \
    116                 --set-threshold 2e-10 \
    117         --save-potentials torsion.potentials], 0, [stdout], [ignore])
     73AT_CHECK([../../molecuilder --parse-homologies $file --set-random-number-engine "lagged_fibonacci607" --random-number-engine-parameters "seed=1;" --set-random-number-distribution "uniform_real" --random-number-distribution-parameters "min=0;max=1;" --fit-potential --potential-type "torsion" --potential-charges 6 6 6 6 --fragment-charges 6 6 6 6 1 1 1 1 1 1 1 1 1 1 --set-threshold 2e-10], 0, [stdout], [ignore])
    11874# check that L_2 error is below 9e-12 ... just 2e-10 otherwise test takes tooo long
    11975AT_CHECK([grep "Best parameters with L2 error" stdout | awk '{if ($8 > 2e-10) exit 1}'], 0, [ignore], [ignore])
    120 AT_CHECK([grep "torsion:.*particle_type1=6,.*particle_type2=6,.*particle_type3=6,.*particle_type4=6,.*spring_constant=.*,.*equilibrium_distance=.*;" torsion.potentials], 0, [ignore], [ignore])
    121 #AT_CHECK([grep "torsion:.*particle_type1=6,.*particle_type2=6,.*particle_type3=6,.*particle_type4=6,.*spring_constant=0.001.*,.*equilibrium_distance=0.99.*;" torsion.potentials], 0, [ignore], [ignore])
     76AT_CHECK([grep "torsion:.*particle_type1=6,.*particle_type2=6,.*particle_type3=6,.*particle_type4=6,.*spring_constant=.*,.*equilibrium_distance=.*;" stdout], 0, [ignore], [ignore])
     77#AT_CHECK([grep "torsion:.*particle_type1=6,.*particle_type2=6,.*particle_type3=6,.*particle_type4=6,.*spring_constant=0.001.*,.*equilibrium_distance=0.99.*;" stdout], 0, [ignore], [ignore])
    12278
    12379AT_CLEANUP
     
    13086AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Potential/FitPotential/pre/$file $file], 0)
    13187AT_CHECK([chmod u+w $file], 0, [ignore], [ignore])
    132 AT_CHECK([../../molecuilder \
    133         --parse-homologies $file \
    134         --set-random-number-engine "lagged_fibonacci607" \
    135                 --random-number-engine-parameters "seed=1;" \
    136         --set-random-number-distribution "uniform_real" \
    137                 --random-number-distribution-parameters "min=0;max=1;" \
    138         --fit-potential \
    139                 --potential-type "improper" \
    140                 --potential-charges 1 7 1 1 \
    141                 --fragment-charges 7 1 1 1 \
    142                 --set-threshold 3e-4 \
    143         --save-potentials improper.potentials], 0, [stdout], [ignore])
     88AT_CHECK([../../molecuilder --parse-homologies $file --set-random-number-engine "lagged_fibonacci607" --random-number-engine-parameters "seed=1;" --set-random-number-distribution "uniform_real" --random-number-distribution-parameters "min=0;max=1;" --fit-potential --potential-type "improper" --potential-charges 1 7 1 1 --fragment-charges 7 1 1 1 --set-threshold 3e-4], 0, [stdout], [ignore])
    14489# check that L_2 error is below 3e-4
    14590AT_CHECK([grep "Best parameters with L2 error" stdout | awk '{if ($8 > 3e-4) exit 1}'], 0, [ignore], [ignore])
    14691# check parameters to printed precision
    147 AT_CHECK([grep "improper:.*particle_type1=1,.*particle_type2=7,.*particle_type3=1,.*particle_type4=1,.*spring_constant=.*,.*equilibrium_distance=.*;" improper.potentials], 0, [ignore], [ignore])
    148 #AT_CHECK([grep "improper:.*particle_type1=1,.*particle_type2=7,.*particle_type3=1,.*particle_type4=1,.*spring_constant=1.02.*,.*equilibrium_distance=0.85.*;" improper.potentials], 0, [ignore], [ignore])
     92AT_CHECK([grep "improper:.*particle_type1=1,.*particle_type2=7,.*particle_type3=1,.*particle_type4=1,.*spring_constant=.*,.*equilibrium_distance=.*;" stdout], 0, [ignore], [ignore])
     93#AT_CHECK([grep "improper:.*particle_type1=1,.*particle_type2=7,.*particle_type3=1,.*particle_type4=1,.*spring_constant=1.02.*,.*equilibrium_distance=0.85.*;" stdout], 0, [ignore], [ignore])
    14994
    15095AT_CLEANUP
     
    157102AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Potential/FitPotential/pre/$file $file], 0)
    158103AT_CHECK([chmod u+w $file], 0, [ignore], [ignore])
    159 AT_CHECK([../../molecuilder \
    160         --parse-homologies $file \
    161         --set-random-number-engine "lagged_fibonacci607" \
    162                 --random-number-engine-parameters "seed=5;" \
    163         --set-random-number-distribution "uniform_real" \
    164                 --random-number-distribution-parameters "min=0;max=1;" \
    165         --fit-potential \
    166                 --potential-type "lennardjones" \
    167                 --potential-charges 18 18 \
    168                 --fragment-charges 18 18 \
    169                 --set-threshold 7e-9 \
    170         --save-potentials lj.potentials], 0, [stdout], [ignore])
     104AT_CHECK([../../molecuilder --parse-homologies $file --set-random-number-engine "lagged_fibonacci607" --random-number-engine-parameters "seed=5;" --set-random-number-distribution "uniform_real" --random-number-distribution-parameters "min=0;max=1;" --fit-potential --potential-type "lennardjones" --potential-charges 18 18 --fragment-charges 18 18 --set-threshold 7e-9], 0, [stdout], [ignore])
    171105# check that L_2 error is below 7e-11 ... just 7e-9 otherwise test takes too long
    172106AT_CHECK([grep "Best parameters with L2 error" stdout | awk '{if ($8 > 7e-9) exit 1}'], 0, [ignore], [ignore])
    173107# check parameters to printed precision
    174 AT_CHECK([grep "lennardjones:.*particle_type1=18,.*particle_type2=18,.*epsilon=.*,.*sigma=.*;" lj.potentials], 0, [ignore], [ignore])
    175 #AT_CHECK([grep "lennardjones:.*particle_type1=18,.*particle_type2=18,.*epsilon=1.*e-05,.*sigma=8.2.*;" lj.potentials], 0, [ignore], [ignore])
     108AT_CHECK([grep "lennardjones:.*particle_type1=18,.*particle_type2=18,.*epsilon=.*,.*sigma=.*;" stdout], 0, [ignore], [ignore])
     109#AT_CHECK([grep "lennardjones:.*particle_type1=18,.*particle_type2=18,.*epsilon=1.*e-05,.*sigma=8.2.*;" stdout], 0, [ignore], [ignore])
    176110
    177111AT_CLEANUP
Note: See TracChangeset for help on using the changeset viewer.