From 708d738e893dcc1bd8b6fdc219dc9495c19789d3 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Mon, 26 Apr 2021 09:04:30 +0200 Subject: [PATCH 01/70] add a tendomer specific updater for reading in crosslink connections --- .../UpdaterReadCrosslinkConnectionsTendomer.h | 231 ++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 include/LeMonADE_PM/updater/UpdaterReadCrosslinkConnectionsTendomer.h diff --git a/include/LeMonADE_PM/updater/UpdaterReadCrosslinkConnectionsTendomer.h b/include/LeMonADE_PM/updater/UpdaterReadCrosslinkConnectionsTendomer.h new file mode 100644 index 0000000..b129114 --- /dev/null +++ b/include/LeMonADE_PM/updater/UpdaterReadCrosslinkConnectionsTendomer.h @@ -0,0 +1,231 @@ +/*-------------------------------------------------------------------------------- + ooo L attice-based | + o\.|./o e xtensible | LeMonADE: An Open Source Implementation of the + o\.\|/./o Mon te-Carlo | Bond-Fluctuation-Model for Polymers +oo---0---oo A lgorithm and | + o/./|\.\o D evelopment | Copyright (C) 2013-2015 by + o/.|.\o E nvironment | LeMonADE Principal Developers (see AUTHORS) + ooo | +---------------------------------------------------------------------------------- + +This file is part of LeMonADE. + +LeMonADE 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. + +LeMonADE 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 LeMonADE. If not, see . + +--------------------------------------------------------------------------------*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * @class UpdaterReadCrosslinkConnectionsTendomer + * @brief reads in connections for a system made of linear chains and crosslinker + * + * @details + * -the input file needs to have a format like: + * #Time, ChainID, MonID1, P1X, P1Y, P1Z, MonID2, P2X, P2Y, P2Z + * -the chains are before the crosslinks in the bfm file + * -the chain length must be at least 1 + * + */ + +template +class UpdaterReadCrosslinkConnectionsTendomer : public AbstractUpdater +{ +public: + UpdaterReadCrosslinkConnectionsTendomer( + IngredientsType& ing_, + const std::string input_, + const double stepwidth_, + const double minConversion_): + ing(ing_), + input(input_), + stepwidth(stepwidth_), + minConversion(minConversion_), + nExecutions(0){}; + virtual void initialize(); + virtual bool execute(); + virtual void cleanup(){}; + +private: + //! container storing system information about monomers + IngredientsType& ing; + + //! container storing system information about monomers + IngredientsType initialIng; + + //! input of the cross link positions and so on.. + const std::string input; + + //!conversion step used in the execute function to increase the conversion + const double stepwidth; + + //! minimal conversion to be read in before further analyse + double minConversion; + + //!number of maximum connections for a cross link + uint32_t NMaxConnection; + + //!numbe of monomers per chain + uint32_t NMonomerPerChain; + + //!number of executions; + uint32_t nExecutions; + + //! connects the cross link to the chain + bool ConnectCrossLinkToChain(uint32_t MonID, uint32_t chainID); + + //!bond Table + std::map,std::vector > bondTable; +}; + + +template +bool UpdaterReadCrosslinkConnectionsTendomer::ConnectCrossLinkToChain(uint32_t MonID, uint32_t chainID){ + std::pair key(MonID,chainID-1); + if (bondTable.find(key) != bondTable.end()){ + if ( !ing.getMolecules().areConnected( MonID,bondTable.at(key)[0] ) ){ + ing.modifyMolecules().connect(MonID,bondTable.at(key)[0] ); + // std::cout << MonID <<"\t" << chainID-1 <<"\t" <1 ) { + ing.modifyMolecules().connect(MonID,bondTable.at(key)[1] ); + // std::cout << MonID <<"\t" << chainID-1 <<"\t" < +void UpdaterReadCrosslinkConnectionsTendomer::initialize(){ + //assume a stochiometric mixture + NMaxConnection=4*ing.getNumCrossLinkers(); + NMonomerPerChain = 2*ing.getNumMonomersPerChain(); + std::cout << "Number of maximum connection: " << NMaxConnection << std::endl; + //erase bonds between reactive monomers + for (uint32_t i =0 ; i < ing.getMolecules().size(); i++) + if (ing.getMolecules()[i].isReactive() ) + for(size_t j=0; j < ing.getMolecules().getNumLinks(i);j++){ + uint32_t neighbor(ing.getMolecules().getNeighborIdx(i,j)); + if (ing.getMolecules()[neighbor].isReactive()){ + ing.modifyMolecules().disconnect(i, neighbor ); + uint32_t chainMonomer(std::min(i,neighbor) ); + uint32_t crosslink(std::max(i,neighbor)); + uint32_t chainID( (chainMonomer-chainMonomer%NMonomerPerChain)/NMonomerPerChain); + // std::cout<<"erase: "<(crosslink,chainID) ].push_back(chainMonomer) ; + } + } + std::cout << "Erase " << bondTable.size() << " bonds." < +bool UpdaterReadCrosslinkConnectionsTendomer::execute(){ + //reset the ingredients container to the inital one + ing = initialIng; + //open input file to the connection table + //! stream reading input file + std::ifstream stream; + stream.open(input); + if (stream.fail()) + throw std::runtime_error(std::string("error opening input file ") + input + std::string("\n")); + bool findStartofData(false); + //set head to beginning of the data block + // while (!findStartofData){ + // std::string line; + // getline(stream, line); + // if (line.empty()) + // findStartofData = true; + // else if (line.at(0) == '#') //go to next line + // continue; + // else + // throw std::runtime_error("Wrong input format!"); + // } + std::string line; + getline(stream, line); + while (line.empty() || line.at(0) == '#' ) + getline(stream, line); + + //current conversion + auto conversion = minConversion + static_cast(nExecutions) * stepwidth; + std::cout << "Current conversion is " <> Time >> createBreak>> ChainID >> nSegments >>MonID1 >> P1X >> P1Y >> P1Z >> MonID2 >> P2X >> P2Y >> P2Z; + // if (NewConnections == 0 ) + // std::cout << Time << " " << ChainID<< " " + // << MonID1<< " " << P1X << " " << P1Y << " " << P1Z << " " + // << MonID2<< " " << P2X << " " << P2Y << " " << P2Z << "\n"; + ing.modifyMolecules().setAge(Time); + // std::cout<<"connect: " << MonID1 << "\t" << ChainID< 0) + // ing.modifyMolecules()[MonID2].modifyVector3D().setAllCoordinates(P2X, P2Y, P2Z); + NewConnections++; + } + std::cout << "Read and add " << NewConnections << "/" << NMaxConnection + << " to the system at time " + << ing.getMolecules().getAge() << std::endl; + ing.synchronize(); + nExecutions++; + std::cout << "UpdaterReadCrosslinkConnectionsTendomer::execute " << nExecutions << " times.\n"; + //close the filestream and return false if the file has ended and thus the updater has nothing more to do + if (stream.eof()) { + stream.close(); + return false; + }else{ + stream.close(); + return true; + } +} From 10c91adff1a975e22ba65783b036f9db8cf3cfc2 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Mon, 26 Apr 2021 09:04:56 +0200 Subject: [PATCH 02/70] add a tendomer specific main program --- projects/CMakeLists.txt | 4 + projects/TendomerNetworkForceEquilibrium.cpp | 184 +++++++++++++++++++ 2 files changed, 188 insertions(+) create mode 100644 projects/TendomerNetworkForceEquilibrium.cpp diff --git a/projects/CMakeLists.txt b/projects/CMakeLists.txt index 08bc816..f7460a7 100644 --- a/projects/CMakeLists.txt +++ b/projects/CMakeLists.txt @@ -1,2 +1,6 @@ add_executable(ForceEquilibrium ForceEquilibrium.cpp) target_link_libraries(ForceEquilibrium LeMonADE CommandlineParser ) + + +add_executable(TendomerNetworkForceEquilibrium TendomerNetworkForceEquilibrium.cpp) +target_link_libraries(TendomerNetworkForceEquilibrium LeMonADE CommandlineParser ) \ No newline at end of file diff --git a/projects/TendomerNetworkForceEquilibrium.cpp b/projects/TendomerNetworkForceEquilibrium.cpp new file mode 100644 index 0000000..3d69388 --- /dev/null +++ b/projects/TendomerNetworkForceEquilibrium.cpp @@ -0,0 +1,184 @@ +/*-------------------------------------------------------------------------------- + ooo L attice-based | + o\.|./o e xtensible | LeMonADE: An Open Source Implementation of the + o\.\|/./o Mon te-Carlo | Bond-Fluctuation-Model for Polymers +oo---0---oo A lgorithm and | + o/./|\.\o D evelopment | Copyright (C) 2013-2015 by + o/.|.\o E nvironment | LeMonADE Principal Developers (see AUTHORS) + ooo | +---------------------------------------------------------------------------------- + +This file is part of LeMonADE. + +LeMonADE 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. + +LeMonADE 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 LeMonADE. If not, see . + +--------------------------------------------------------------------------------*/ + +/****************************************************************************** + * based on LeMonADE: https://github.com/LeMonADE-project/LeMonADE/ + * author: Toni Müller + * email: mueller-toni@ipfdd.de + * project: LeMonADE-Phantom Modulus + *****************************************************************************/ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + + +int main(int argc, char* argv[]){ + try{ + /////////////////////////////////////////////////////////////////////////////// + ///parse options/// + std::string inputBFM("init.bfm"); + std::string outputDataPos("CrosslinkPosition.dat"); + std::string outputDataDist("ChainExtensionDistribution.dat"); + std::string inputConnection("BondCreationBreaking.dat"); + std::string feCurve(""); + double relaxationParameter(10.); + double threshold(0.5); + double stepwidth(1.0); + double minConversion(50.0); + + bool showHelp = false; + auto parser + = clara::detail::Opt( inputBFM, "inputBFM (=inconfig.bfm)" ) ["-i"]["--input" ] ("(required)Input filename of the bfm file" ).required() + | clara::detail::Opt( inputConnection, "inputConnection (=BondCreationBreaking.dat)" ) ["-d"]["--inputConnection"] ("used for the time development of the topology. " ).required() + | clara::detail::Opt( outputDataPos, "outputDataPos (=CrosslinkPosition.dat)" ) ["-o"]["--outputPos" ] ("(optional) Output filename of the crosslink ID and the equilibrium Position.").optional() + | clara::detail::Opt( outputDataDist, "outputDataDist (=ChainExtensionDistribution.dat)") ["-c"]["--outputDist" ] ("(optional) Output filename of the chain extension distribution." ).optional() + | clara::detail::Opt( stepwidth, "stepwidth" ) ["-s"]["--stepwidth" ] ("(optional) Width for the increase in percentage. Default: 1%." ).optional() + | clara::detail::Opt( minConversion, "minConversion" ) ["-u"]["--minConversion" ] ("(optional) Minimum conversion to be read in. Default: 50%." ).optional() + | clara::detail::Opt( threshold, "threshold" ) ["-t"]["--threshold" ] ("(optional) Threshold of the average shift. Default 0.5 ." ).optional() + | clara::detail::Opt( feCurve, "feCurve (="")" ) ["-f"]["--feCurve" ] ("(optional) Force-Extension curve. Default \"\"." ).required() + | clara::detail::Opt( relaxationParameter, "relaxationParameter (=10)" ) ["-r"]["--relax" ] ("(optional) Relaxation parameter. Default 10.0 ." ).optional() + | clara::Help( showHelp ); + + auto result = parser.parse( clara::Args( argc, argv ) ); + + if( !result ) { + std::cerr << "Error in command line: " << result.errorMessage() << std::endl; + exit(1); + }else if(showHelp == true){ + std::cout << "Simulator to connect linear chains with single monomers of certain functionality"<< std::endl; + parser.writeToStream(std::cout); + exit(0); + }else{ + std::cout << "outputData : " << outputDataPos << std::endl; + std::cout << "outputDataDist : " << outputDataDist << std::endl; + std::cout << "inputBFM : " << inputBFM << std::endl; + std::cout << "inputConnection : " << inputConnection << std::endl; + std::cout << "stepwidth : " << stepwidth << std::endl; + std::cout << "minConversion : " << minConversion << std::endl; + std::cout << "threshold : " << threshold << std::endl; + std::cout << "feCurve : " << feCurve << std::endl; + } + + /////////////////////////////////////////////////////////////////////////////// + ///end options parsing + /////////////////////////////////////////////////////////////////////////////// + //Read in th last Config + typedef LOKI_TYPELIST_3(FeatureMoleculesIOUnsaveCheck, FeatureLabel, FeatureReactiveBonds) Features; + typedef ConfigureSystem Config; + typedef Ingredients Ing; + Ing myIngredients; + + TaskManager taskmanager; + + taskmanager.addUpdater( new UpdaterReadBfmFile(inputBFM,myIngredients, UpdaterReadBfmFile::READ_LAST_CONFIG_SAVE),0); + + //initialize and run + taskmanager.initialize(); + taskmanager.run(1); + taskmanager.cleanup(); + std::cout << "Read in conformation and go on to bring it into equilibrium forces..." < Config2; + typedef Ingredients Ing2; + Ing2 myIngredients2; + + myIngredients2.setBoxX(myIngredients.getBoxX()); + myIngredients2.setBoxY(myIngredients.getBoxY()); + myIngredients2.setBoxZ(myIngredients.getBoxZ()); + myIngredients2.setPeriodicX(myIngredients.isPeriodicX()); + myIngredients2.setPeriodicY(myIngredients.isPeriodicY()); + myIngredients2.setPeriodicZ(myIngredients.isPeriodicZ()); + myIngredients2.modifyMolecules().resize(myIngredients.getMolecules().size()); + myIngredients2.modifyMolecules().setAge(myIngredients.getMolecules().getAge()); + + // myIngredients2.setNumOfChains (myIngredients.getNumOfChains()); + // myIngredients2.setNumOfCrosslinks (myIngredients.getNumOfCrosslinks()); + // myIngredients2.setNumOfMonomersPerChain (myIngredients.getNumOfMonomersPerChain()); + // myIngredients2.setNumOfMonomersPerCrosslink(myIngredients.getNumOfMonomersPerCrosslink()); + // myIngredients2.setFunctionality (myIngredients.getFunctionality()); + + myIngredients2.setNumTendomers (myIngredients.getNumTendomers()); + myIngredients2.setNumCrossLinkers (myIngredients.getNumCrossLinkers()); + myIngredients2.setNumMonomersPerChain (myIngredients.getNumMonomersPerChain()); + myIngredients2.setNumLabelsPerTendomerArm(myIngredients.getNumLabelsPerTendomerArm()); + + for(size_t i = 0; i< myIngredients.getMolecules().size();i++){ + myIngredients2.modifyMolecules()[i].modifyVector3D()=myIngredients.getMolecules()[i].getVector3D(); + myIngredients2.modifyMolecules()[i].setReactive(myIngredients.getMolecules()[i].isReactive()); + myIngredients2.modifyMolecules()[i].setNumMaxLinks(myIngredients.getMolecules()[i].getNumMaxLinks()); + for (size_t j = 0 ; j < myIngredients.getMolecules().getNumLinks(i);j++){ + uint32_t neighbor(myIngredients.getMolecules().getNeighborIdx(i,j)); + if( ! myIngredients2.getMolecules().areConnected(i,neighbor) ) + myIngredients2.modifyMolecules().connect(i,neighbor); + } + } + myIngredients2.synchronize(); + + TaskManager taskmanager2; + //read bonds and positions stepwise + taskmanager2.addUpdater( new UpdaterReadCrosslinkConnectionsTendomer(myIngredients2, inputConnection, stepwidth, minConversion) ); + // auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; + // updater->setFilename(feCurve); + // updater->setRelaxationParameter(relaxationParameter); + auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; + taskmanager2.addUpdater( updater ); + taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,outputDataPos, outputDataDist)); + //initialize and run + taskmanager2.initialize(); + taskmanager2.run(); + taskmanager2.cleanup(); + + } + catch(std::exception& e){ + std::cerr<<"Error:\n" + < Date: Tue, 27 Apr 2021 07:56:12 +0200 Subject: [PATCH 03/70] Add a TendomerNetworkForceEquilibrium program which read a custom FE curve for calculating the force. --- ...atureCrosslinkConnectionsLookUpTendomers.h | 158 ++++++++++++++++++ .../updater/UpdaterForceBalancedPosition.h | 22 +-- .../UpdaterForceBalancedPositionTendomer.h | 104 ++++++++++++ .../UpdaterReadCrosslinkConnectionsTendomer.h | 30 ---- .../moves/MoveNonLinearForceEquilibrium.h | 8 +- projects/CMakeLists.txt | 4 +- projects/TendomerNetworkForceEquilibrium.cpp | 12 +- .../TestUpdaterForceBalancedPosition.cpp | 12 +- 8 files changed, 287 insertions(+), 63 deletions(-) create mode 100644 include/LeMonADE_PM/feature/FeatureCrosslinkConnectionsLookUpTendomers.h create mode 100644 include/LeMonADE_PM/updater/UpdaterForceBalancedPositionTendomer.h diff --git a/include/LeMonADE_PM/feature/FeatureCrosslinkConnectionsLookUpTendomers.h b/include/LeMonADE_PM/feature/FeatureCrosslinkConnectionsLookUpTendomers.h new file mode 100644 index 0000000..409aae0 --- /dev/null +++ b/include/LeMonADE_PM/feature/FeatureCrosslinkConnectionsLookUpTendomers.h @@ -0,0 +1,158 @@ +/*-------------------------------------------------------------------------------- + ooo L attice-based | + o\.|./o e xtensible | LeMonADE: An Open Source Implementation of the + o\.\|/./o Mon te-Carlo | Bond-Fluctuation-Model for Polymers +oo---0---oo A lgorithm and | + o/./|\.\o D evelopment | Copyright (C) 2013-2015 by + o/.|.\o E nvironment | LeMonADE Principal Developers (see AUTHORS) + ooo | +---------------------------------------------------------------------------------- + +This file is part of LeMonADE. + +LeMonADE 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. + +LeMonADE 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 LeMonADE. If not, see . + +--------------------------------------------------------------------------------*/ + + +#ifndef LENONADE_PM_FEATURE_FEATURECROSSLINKCONNECTIONLOOKUPTENDOMERS_H +#define LENONADE_PM_FEATURE_FEATURECROSSLINKCONNECTIONLOOKUPTENDOMERS_H + +#include +#include +#include +#include +#include +#include + + +/*****************************************************************************/ +/** + * @file + * @date 2021/04/01 + * @author Toni + * + * @class FeatureCrosslinkConnectionsLookUpTendomers + * @brief Creates a lookup for crosslink IDs and their neighbors + * @details For calculating the equilibrium position of crosslinks in a + * a phantom network, one needs to know the crosslink neighbors and the number + * of segments between them. + * + **/ +/*****************************************************************************/ +/////////////////////////////////////////////////////////////////////////////// +//DEFINITION OF THE CLASS TEMPLATE /////// +//Implementation of the members below /////// +/////////////////////////////////////////////////////////////////////////////// + +class FeatureCrosslinkConnectionsLookUpTendomers : public Feature { + +public: + //! This Feature requires a monomer_extensions. + typedef LOKI_TYPELIST_1(MonomerReactivity) monomer_extensions; + + //! check bas connect move - always true + template + bool checkMove(const IngredientsType& ingredients, const MoveBase& move) const { return true;}; + + //! synchronize lookup table + template + void synchronize(IngredientsType& ingredients) { + fillTables(ingredients); + }; + + //!getter function for the neighboring crosslinks + std::vector getCrossLinkNeighborIDs(uint32_t CrossLinkID) const{ + if (CrossLinkNeighbors.find(CrossLinkID) == CrossLinkNeighbors.end()){ + std::stringstream errormessage; + errormessage << "FeatureCrosslinkConnectionsLookUpTendomers::getCrossLinkNeighborIDs Cross Link ID " << CrossLinkID <<" does not exist."; + throw std::runtime_error(errormessage.str()); + } + return CrossLinkNeighbors.at(CrossLinkID); + }; + + //!get the ID of crosslinks (determined by nConnections>3 and connected to another crosslink) + const std::vector& getCrosslinkIDs() const {return crosslinkIDs;} + +private: + //! convinience function to fill all tables + template + void fillTables(IngredientsType& ingredients); + //!key - CrossLink ID; value - neighboring cross link and the number of segments to them + std::map > CrossLinkNeighbors; + //!ID for crosslinks + std::vector crosslinkIDs; +}; +/** + *@details Create look up table + **/ +template +void FeatureCrosslinkConnectionsLookUpTendomers::fillTables(IngredientsType& ingredients){ + + const typename IngredientsType::molecules_type& molecules=ingredients.getMolecules(); + std::cout << "FeatureCrosslinkConnectionsLookUpTendomers::fillTables" < 2 ){ + //temporary storage for the neighboring crosslinks + std::vector NeighborIDs; + auto posX(molecules[i].getVector3D()); + for (size_t j = 0 ; j < molecules.getNumLinks(i); j++){ + uint32_t tail(i); + uint32_t head(molecules.getNeighborIdx(i,j)); + VectorDouble3 posHead(molecules[head].getVector3D()); + VectorDouble3 bond(LemonadeDistCalcs::MinImageVector( posX,posHead,ingredients)); + if(bond.getLength() > std::sqrt(10)){ + std::stringstream errormessage; + errormessage << "FeatureCrosslinkConnectionsLookUpTendomers: Wrong bond " << bond << " between " << i << " and " << head << "\n"; + throw std::runtime_error(errormessage.str()); + } + VectorDouble3 jumpVector(posHead-bond-posX); // tracks if one bond jumps across periodic images + //go to tendomer end + tail=(head/nMonomersPerChain % 2 == 0 ) ? head +nMonomersPerChain : head-nMonomersPerChain; + //cross links are connected by a chain + if( molecules.getNumLinks(tail) == 2 ){ + //get crosslink + for (size_t k = 0 ; k < molecules.getNumLinks(tail); k++){ + uint32_t NextMonomer( molecules.getNeighborIdx(tail,k)); + if( molecules[NextMonomer].isReactive() && molecules[NextMonomer].getNumMaxLinks() > 2 ){ + head=NextMonomer; + break; + } + } + posHead=molecules[head].getVector3D(); + auto posTail=molecules[tail].getVector3D(); + bond=LemonadeDistCalcs::MinImageVector( posTail,posHead,ingredients); + jumpVector+=(posHead-bond-posTail); // tracks if one bond jumps across periodic images + // auto vecJ(jumpVector); + // vecJ.setAllCoordinates( + // static_cast(jumpVector.getX()) % 256 , + // static_cast(jumpVector.getY()) % 256 , + // static_cast(jumpVector.getZ()) % 256 ); + + // std::cout << "Jumpvector=" << jumpVector << " for ID=" << i << " to " << head << ": " < bool UpdaterForceBalancedPosition::execute(){ @@ -101,8 +86,9 @@ bool UpdaterForceBalancedPosition::execute(){ }else avShift=threshold*1.1; ing.modifyMolecules().setAge(ing.getMolecules().getAge()+1); - if (ing.getMolecules().getAge() %1000 == 0 ) + if (ing.getMolecules().getAge() %1000 == 0 ){ std::cout << "MCS: " << ing.getMolecules().getAge() << " and average shift: " << avShift << std::endl; + } } std::cout << "Finish equilibration with average shift per cross link < " << avShift << " after " << ing.getMolecules().getAge()-StartMCS <. + +--------------------------------------------------------------------------------*/ +#ifndef LEMONADE_PM_UPDATER_UPDATERFORCEBALANCEPOSITION_H +#define LEMONADE_PM_UPDATER_UPDATERFORCEBALANCEPOSITION_H + + +#include +#include + /** + * @class UpdaterForceBalancedPosition + * @tparam IngredientsType + */ + + template +class UpdaterForceBalancedPosition:public AbstractUpdater +{ +public: + //! constructor for UpdaterForceBalancedPosition + UpdaterForceBalancedPosition(IngredientsType& ing_, double threshold_ ): + ing(ing_),threshold(threshold_){}; + + virtual void initialize(){relaxationParameter=move.getRelaxationParameter();}// init(move);}; + bool execute(); + virtual void cleanup(){}; + + void setFilename(const std::string filename) {move.setFilename(filename); } + void setRelaxationParameter( const double relax ) {move.setRelaxationParameter(relax);} +private: + //!copy of the main container for the system informations + IngredientsType& ing; + + //! threshold for the certainty + double threshold; + + double relaxationParameter; + + //! move to equilibrate the cross links by force equilibrium + moveType move; + + //! random number generator + RandomNumberGenerators rng; + +}; +template +bool UpdaterForceBalancedPosition::execute(){ + std::cout << "UpdaterForceBalancedPosition::execute(): Start equilibration" < threshold ){ + double NSuccessfulMoves(0.); + avShift=0.0; + for (uint32_t i =0 ; i0 ){ + avShift/=(NSuccessfulMoves); + }else + avShift=threshold*1.1; + ing.modifyMolecules().setAge(ing.getMolecules().getAge()+1); + if (ing.getMolecules().getAge() %1000 == 0 ){ + std::cout << "MCS: " << ing.getMolecules().getAge() << " and average shift: " << avShift << std::endl; + setRelaxationParameter(move.getRelaxationParameter()*0.99 ); + } + } + std::cout << "Finish equilibration with average shift per cross link < " << avShift << " after " << ing.getMolecules().getAge()-StartMCS <,std::vector > bondTable; }; - - template bool UpdaterReadCrosslinkConnectionsTendomer::ConnectCrossLinkToChain(uint32_t MonID, uint32_t chainID){ std::pair key(MonID,chainID-1); if (bondTable.find(key) != bondTable.end()){ if ( !ing.getMolecules().areConnected( MonID,bondTable.at(key)[0] ) ){ ing.modifyMolecules().connect(MonID,bondTable.at(key)[0] ); - // std::cout << MonID <<"\t" << chainID-1 <<"\t" <1 ) { ing.modifyMolecules().connect(MonID,bondTable.at(key)[1] ); - // std::cout << MonID <<"\t" << chainID-1 <<"\t" <::initialize(){ uint32_t chainMonomer(std::min(i,neighbor) ); uint32_t crosslink(std::max(i,neighbor)); uint32_t chainID( (chainMonomer-chainMonomer%NMonomerPerChain)/NMonomerPerChain); - // std::cout<<"erase: "<(crosslink,chainID) ].push_back(chainMonomer) ; } } @@ -159,22 +152,10 @@ bool UpdaterReadCrosslinkConnectionsTendomer::execute(){ if (stream.fail()) throw std::runtime_error(std::string("error opening input file ") + input + std::string("\n")); bool findStartofData(false); - //set head to beginning of the data block - // while (!findStartofData){ - // std::string line; - // getline(stream, line); - // if (line.empty()) - // findStartofData = true; - // else if (line.at(0) == '#') //go to next line - // continue; - // else - // throw std::runtime_error("Wrong input format!"); - // } std::string line; getline(stream, line); while (line.empty() || line.at(0) == '#' ) getline(stream, line); - //current conversion auto conversion = minConversion + static_cast(nExecutions) * stepwidth; std::cout << "Current conversion is " <::execute(){ uint32_t Time, createBreak, ChainID, nSegments, MonID1, P1X, P1Y, P1Z, MonID2, P2X, P2Y, P2Z; ss << line; ss >> Time >> createBreak>> ChainID >> nSegments >>MonID1 >> P1X >> P1Y >> P1Z >> MonID2 >> P2X >> P2Y >> P2Z; - // if (NewConnections == 0 ) - // std::cout << Time << " " << ChainID<< " " - // << MonID1<< " " << P1X << " " << P1Y << " " << P1Z << " " - // << MonID2<< " " << P2X << " " << P2Y << " " << P2Z << "\n"; ing.modifyMolecules().setAge(Time); - // std::cout<<"connect: " << MonID1 << "\t" << ChainID< 0) - // ing.modifyMolecules()[MonID2].modifyVector3D().setAllCoordinates(P2X, P2Y, P2Z); NewConnections++; } std::cout << "Read and add " << NewConnections << "/" << NMaxConnection diff --git a/include/LeMonADE_PM/updater/moves/MoveNonLinearForceEquilibrium.h b/include/LeMonADE_PM/updater/moves/MoveNonLinearForceEquilibrium.h index 973fc96..529d9d5 100644 --- a/include/LeMonADE_PM/updater/moves/MoveNonLinearForceEquilibrium.h +++ b/include/LeMonADE_PM/updater/moves/MoveNonLinearForceEquilibrium.h @@ -140,7 +140,8 @@ class MoveNonLinearForceEquilibrium:public MoveForceEquilibriumBase 0) { VectorDouble3 Position(ing.getMolecules()[this->getIndex()].getVector3D()); for (size_t i = 0; i < Neighbors.size(); i++){ - VectorDouble3 vec(Position-ing.getMolecules()[Neighbors[i].ID].getVector3D()-Neighbors[i].jump); + VectorDouble3 vec(Position-ing.getMolecules()[Neighbors[i].ID].getVector3D()+Neighbors[i].jump); + // std::cout << Position << " " << ing.getMolecules()[Neighbors[i].ID].getVector3D() << " " << Neighbors[i].jump <<"\n"; force+=EF(vec);//Neighbors[i].segDistance } shift=FE(force/(static_cast(Neighbors.size()) )); @@ -196,6 +197,11 @@ void MoveNonLinearForceEquilibrium::createTable(){ } } } + std::cout << "MoveNonLinearForceEquilibrium::createTable(): \n" + << "min_force=" << min_force <<"\n" + << "max_force=" << max_force <<"\n" + << "min_extension=" << min_extension <<"\n" + << "max_extension=" << max_extension <<"\n"; } /*****************************************************************************/ /** diff --git a/projects/CMakeLists.txt b/projects/CMakeLists.txt index f7460a7..5780870 100644 --- a/projects/CMakeLists.txt +++ b/projects/CMakeLists.txt @@ -1,5 +1,5 @@ -add_executable(ForceEquilibrium ForceEquilibrium.cpp) -target_link_libraries(ForceEquilibrium LeMonADE CommandlineParser ) +# add_executable(ForceEquilibrium ForceEquilibrium.cpp) +# target_link_libraries(ForceEquilibrium LeMonADE CommandlineParser ) add_executable(TendomerNetworkForceEquilibrium TendomerNetworkForceEquilibrium.cpp) diff --git a/projects/TendomerNetworkForceEquilibrium.cpp b/projects/TendomerNetworkForceEquilibrium.cpp index 3d69388..7221ab7 100644 --- a/projects/TendomerNetworkForceEquilibrium.cpp +++ b/projects/TendomerNetworkForceEquilibrium.cpp @@ -50,7 +50,7 @@ along with LeMonADE. If not, see . #include #include #include -#include +#include #include @@ -120,7 +120,7 @@ int main(int argc, char* argv[]){ taskmanager.cleanup(); std::cout << "Read in conformation and go on to bring it into equilibrium forces..." < Config2; typedef Ingredients Ing2; Ing2 myIngredients2; @@ -160,10 +160,10 @@ int main(int argc, char* argv[]){ TaskManager taskmanager2; //read bonds and positions stepwise taskmanager2.addUpdater( new UpdaterReadCrosslinkConnectionsTendomer(myIngredients2, inputConnection, stepwidth, minConversion) ); - // auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; - // updater->setFilename(feCurve); - // updater->setRelaxationParameter(relaxationParameter); - auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; + auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; + updater->setFilename(feCurve); + updater->setRelaxationParameter(relaxationParameter); + // auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; taskmanager2.addUpdater( updater ); taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,outputDataPos, outputDataDist)); //initialize and run diff --git a/tests/updater/TestUpdaterForceBalancedPosition.cpp b/tests/updater/TestUpdaterForceBalancedPosition.cpp index 277c7ab..8155cee 100644 --- a/tests/updater/TestUpdaterForceBalancedPosition.cpp +++ b/tests/updater/TestUpdaterForceBalancedPosition.cpp @@ -127,12 +127,12 @@ TEST_CASE( "Test class UpdaterForceBalancedPosition" ) REQUIRE(ingredients.getMolecules().size()==13 ); REQUIRE_NOTHROW(ingredients.synchronize(ingredients)); //check some basics - UpdaterForceBalancedPosition updater(ingredients, 0.0001); - updater.execute(); - auto vec2=LemonadeDistCalcs::MinImageVector(VectorDouble3(0.,0.,0.),ingredients.getMolecules()[0].getVector3D(),ingredients ); - REQUIRE(vec2.getX() == Approx(5.3125)); - REQUIRE(vec2.getY() == Approx(6.375)); - REQUIRE(vec2.getZ() == Approx(5.8125)); + // UpdaterForceBalancedPosition updater(ingredients, 0.0001); + // updater.execute(); + // auto vec2=LemonadeDistCalcs::MinImageVector(VectorDouble3(0.,0.,0.),ingredients.getMolecules()[0].getVector3D(),ingredients ); + // REQUIRE(vec2.getX() == Approx(5.3125)); + // REQUIRE(vec2.getY() == Approx(6.375)); + // REQUIRE(vec2.getZ() == Approx(5.8125)); } //restore cout std::cout.rdbuf(originalBuffer); From b7fe3554e59bbed21df5506a4912c288ac38da60 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Mon, 10 May 2021 08:55:51 +0200 Subject: [PATCH 04/70] Finalize the force equilibration process for the tendomer networks. --- .../analyzer/AnalyzerEquilbratedPosition.h | 4 +- .../UpdaterForceBalancedPositionTendomer.h | 18 +-- .../moves/MoveNonLinearForceEquilibrium.h | 110 ++++++++++-------- projects/TendomerNetworkForceEquilibrium.cpp | 4 +- 4 files changed, 77 insertions(+), 59 deletions(-) diff --git a/include/LeMonADE_PM/analyzer/AnalyzerEquilbratedPosition.h b/include/LeMonADE_PM/analyzer/AnalyzerEquilbratedPosition.h index ea38b60..eb5961d 100644 --- a/include/LeMonADE_PM/analyzer/AnalyzerEquilbratedPosition.h +++ b/include/LeMonADE_PM/analyzer/AnalyzerEquilbratedPosition.h @@ -196,7 +196,7 @@ void AnalyzerEquilbratedPosition::dumpData() commentAveragePosition<<"conversion="<::dumpData() commentDistribution<<"Chain ID's start at 1 \n"; commentDistribution<<"ID1 ID2 vector length ChainID \n"; std::stringstream outDist; - outDist<< std::setprecision(2) << "C" << conversion; + outDist<< std::setprecision(3) << "C" << conversion; outDist << "_" << outDistBasename; ResultFormattingTools::writeResultFile( diff --git a/include/LeMonADE_PM/updater/UpdaterForceBalancedPositionTendomer.h b/include/LeMonADE_PM/updater/UpdaterForceBalancedPositionTendomer.h index 912487b..0df7f26 100644 --- a/include/LeMonADE_PM/updater/UpdaterForceBalancedPositionTendomer.h +++ b/include/LeMonADE_PM/updater/UpdaterForceBalancedPositionTendomer.h @@ -24,23 +24,23 @@ You should have received a copy of the GNU General Public License along with LeMonADE. If not, see . --------------------------------------------------------------------------------*/ -#ifndef LEMONADE_PM_UPDATER_UPDATERFORCEBALANCEPOSITION_H -#define LEMONADE_PM_UPDATER_UPDATERFORCEBALANCEPOSITION_H +#ifndef LEMONADE_PM_UPDATER_UPDATERFORCEBALANCEPOSITIONTENDOMER_H +#define LEMONADE_PM_UPDATER_UPDATERFORCEBALANCEPOSITIONTENDOMER_H #include #include /** - * @class UpdaterForceBalancedPosition + * @class UpdaterForceBalancedPositionTendomer * @tparam IngredientsType */ template -class UpdaterForceBalancedPosition:public AbstractUpdater +class UpdaterForceBalancedPositionTendomer:public AbstractUpdater { public: - //! constructor for UpdaterForceBalancedPosition - UpdaterForceBalancedPosition(IngredientsType& ing_, double threshold_ ): + //! constructor for UpdaterForceBalancedPositionTendomer + UpdaterForceBalancedPositionTendomer(IngredientsType& ing_, double threshold_ ): ing(ing_),threshold(threshold_){}; virtual void initialize(){relaxationParameter=move.getRelaxationParameter();}// init(move);}; @@ -66,8 +66,8 @@ class UpdaterForceBalancedPosition:public AbstractUpdater }; template -bool UpdaterForceBalancedPosition::execute(){ - std::cout << "UpdaterForceBalancedPosition::execute(): Start equilibration" <::execute(){ + std::cout << "UpdaterForceBalancedPositionTendomer::execute(): Start equilibration" <::execute(){ ing.modifyMolecules().setAge(ing.getMolecules().getAge()+1); if (ing.getMolecules().getAge() %1000 == 0 ){ std::cout << "MCS: " << ing.getMolecules().getAge() << " and average shift: " << avShift << std::endl; - setRelaxationParameter(move.getRelaxationParameter()*0.99 ); + setRelaxationParameter(move.getRelaxationParameter()*0.995 ); } } std::cout << "Finish equilibration with average shift per cross link < " << avShift << " after " << ing.getMolecules().getAge()-StartMCS <. #define LEMONADE_PM_UPDATER_MOVES_MOVENONLINEARFORCEEQUILIBRIUM_H #include #include +#include #include #include #include @@ -148,60 +149,77 @@ class MoveNonLinearForceEquilibrium:public MoveForceEquilibriumBase>force >> extension; - if(min_force > force ) min_force=force; - if(max_force < force ) max_force=force; - if(min_extension > extension ) min_extension=extension; - if(max_extension < extension ) max_extension=extension; - extension_force.insert(extension_force.end(),std::pair(force, extension)); - if(counter==1){ - force_steps=max_force-min_force; - }else if(counter>1) - counter++; - } - in.close(); - //make lookup for the extension force relation - //make a entry from 0 to max_extension in steps of 1 - for ( auto r=0;r(max_extension); r++ ){ - if(r==0) - force_extension.push_back(0.); - else{ - auto it_last=extension_force.begin(); - for (auto it=extension_force.begin(); it !=extension_force.end();it++){ - if(it->second > r){ - //at the force linear interpolated in between the two current forces - auto deltaForce(it->first-it_last->first); - auto deltaExtension(it->second-it_last->second); - auto factor( (static_cast(r)-it_last->second)/deltaExtension ); - //at interpolated force - force_extension.push_back(it_last->first+deltaForce*factor); - break; + if (fileExists(filename )){ + std::ifstream in(filename); + uint32_t counter(0); + extension_force.insert(extension_force.end(),std::pair(0., 0.)); + min_force=0.; + min_extension=0.; + while(in.good() && in.peek()!=EOF){ + std::string line; + getline(in, line); + //ignore comments and blank lines + while (line.at(0) == '#' || line.empty() ) //go to next line + continue; + //read data + double force, extension; + std::stringstream ss ; + ss<< line; + ss>>force >> extension; + if(min_force > force ) min_force=force; + if(max_force < force ) max_force=force; + if(min_extension > extension ) min_extension=extension; + if(max_extension < extension ) max_extension=extension; + extension_force.insert(extension_force.end(),std::pair(force, extension)); + if(counter==1){ + force_steps=max_force-min_force; + }else if(counter>1) + counter++; + } + in.close(); + //make lookup for the extension force relation + //make a entry from 0 to max_extension in steps of 1 + for ( auto r=0;r(max_extension); r++ ){ + if(r==0) + force_extension.push_back(0.); + else{ + auto it_last=extension_force.begin(); + for (auto it=extension_force.begin(); it !=extension_force.end();it++){ + if(it->second > r){ + //at the force linear interpolated in between the two current forces + auto deltaForce(it->first-it_last->first); + auto deltaExtension(it->second-it_last->second); + auto factor( (static_cast(r)-it_last->second)/deltaExtension ); + //at interpolated force + force_extension.push_back(it_last->first+deltaForce*factor); + break; + } + it_last=it; } - it_last=it; } } + std::cout << "MoveNonLinearForceEquilibrium::createTable() force extension" <. #include -#include +#include #include #include #include @@ -160,7 +160,7 @@ int main(int argc, char* argv[]){ TaskManager taskmanager2; //read bonds and positions stepwise taskmanager2.addUpdater( new UpdaterReadCrosslinkConnectionsTendomer(myIngredients2, inputConnection, stepwidth, minConversion) ); - auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; + auto updater = new UpdaterForceBalancedPositionTendomer(myIngredients2, threshold) ; updater->setFilename(feCurve); updater->setRelaxationParameter(relaxationParameter); // auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; From d615cb9e755ef8ce46c31da433e587707cd06b79 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Fri, 4 Jun 2021 07:03:48 +0200 Subject: [PATCH 05/70] add an analysis which extracts the active part of the tendomer gel --- .../AnalyzerConnectionDistributions.h | 128 ++++++++++ .../AnalyzerIntramolecularReactions.h | 168 +++++++++++++ projects/CMakeLists.txt | 9 +- projects/ForceEquilibrium.cpp | 3 + projects/IntramolecularReactions.cpp | 170 ++++++++++++++ projects/TendomerNetworkExtractActivePart.cpp | 220 ++++++++++++++++++ projects/TendomerNetworkForceEquilibrium.cpp | 23 +- ...etworkForceEquilibriumConversionSeries.cpp | 186 +++++++++++++++ 8 files changed, 889 insertions(+), 18 deletions(-) create mode 100644 include/LeMonADE_PM/analyzer/AnalyzerConnectionDistributions.h create mode 100644 include/LeMonADE_PM/analyzer/AnalyzerIntramolecularReactions.h create mode 100644 projects/IntramolecularReactions.cpp create mode 100644 projects/TendomerNetworkExtractActivePart.cpp create mode 100644 projects/TendomerNetworkForceEquilibriumConversionSeries.cpp diff --git a/include/LeMonADE_PM/analyzer/AnalyzerConnectionDistributions.h b/include/LeMonADE_PM/analyzer/AnalyzerConnectionDistributions.h new file mode 100644 index 0000000..2e43939 --- /dev/null +++ b/include/LeMonADE_PM/analyzer/AnalyzerConnectionDistributions.h @@ -0,0 +1,128 @@ +/****************************************************************************** + * based on LeMonADE: https://github.com/LeMonADE-project/LeMonADE/ + * author: Toni Müller + * email: mueller-toni@ipfdd.de + * project: Phantom Modulus + *****************************************************************************/ + +#ifndef LEMONADE_PM_ANALYZER_ANALYZERINTRAMOLECULARREACTIONS_H +#define LEMONADE_PM_ANALYZER_ANALYZERINTRAMOLECULARREACTIONS_H + +#include + +#include +#include +#include +#include +#include + +/************************************************************************* + * definition of AnalyzerIntramolecularReactions class + * ***********************************************************************/ + +/** + * @file + * + * @class AnalyzerIntramolecularReactions + * + * @brief Analyzes the connection distribution of chains and cross linker for the whole system, + * the gel and the active part of the gel. + * + * @tparam IngredientsType Ingredients class storing all system information( e.g. monomers, bonds, etc). + */ +template < class IngredientsType > class AnalyzerIntramolecularReactions : public AbstractAnalyzer +{ + +private: + //! typedef for the underlying container holding the monomers + typedef typename IngredientsType::molecules_type molecules_type; + + //! reference to the complete system + const IngredientsType& ingredients; +public: + //! constructor + AnalyzerIntramolecularReactions(const IngredientsType& ingredients_, std::string outputFilename_); + + //! destructor. does nothing + virtual ~AnalyzerIntramolecularReactions(){} + + //! Initializes data structures. Called by TaskManager::initialize() + virtual void initialize(); + + //! Calculates the Rg2 for the current timestep. Called by TaskManager::execute() + virtual bool execute(); + + //! Writes the final results to file + virtual void cleanup(); + + //! name of output file for the average is outputFilePrefix_averages.dat + std::string outputFilename; + + //! save the current values in Rg2TimeSeriesX, etc., to disk + void dumpData(); + + //! calculates the distance between crosslinks and stores IDs, distance vector and chainID + std::vector< std::vector > CalculateDistance(); + + //! just collects the id and the position for the cross links + std::vector > CollectAveragePositions(); +}; + +/************************************************************************* + * implementation of memebers + * ***********************************************************************/ + +/** + * @param ing reference to the object holding all information of the system + * */ +template +AnalyzerIntramolecularReactions::AnalyzerIntramolecularReactions( + const IngredientsType& ingredients_, std::string outputFilename_) +:ingredients(ingredients_) +,outputFilename(outputFilename_) +{} +//////////////////////////////////////////////////////////////////////////////// +/** + * @brief calculates the average distances between monomers and their distribution + * */ +template< class IngredientsType > +void AnalyzerIntramolecularReactions::initialize(){} +/** + * @details + * */ +template< class IngredientsType > +bool AnalyzerIntramolecularReactions::execute() +{ + dumpData(); + return true; +} +template +void AnalyzerIntramolecularReactions::cleanup() +{ + dumpData(); +} + + +template +void AnalyzerIntramolecularReactions::dumpData() +{ + + //output for the equilibrated positions + std::vector< std::vector > CrossLinkPositions=CollectAveragePositions() ; + std::stringstream commentAveragePosition; + commentAveragePosition<<"Created by AnalyzerIntramolecularReactions\n"; + commentAveragePosition<<"conversion nBonds nIntraBonds nBondsGel nIntraBondsGels \n"; + + ResultFormattingTools::writeResultFile( + outputFilename, + ingredients, + CrossLinkPositions, + commentAveragePosition.str() + ); + + +} + +#endif /*LEMONADE_PM_ANALYZER_ANALYZERINTRAMOLECULARREACTIONS_H*/ + + diff --git a/include/LeMonADE_PM/analyzer/AnalyzerIntramolecularReactions.h b/include/LeMonADE_PM/analyzer/AnalyzerIntramolecularReactions.h new file mode 100644 index 0000000..5a5fb11 --- /dev/null +++ b/include/LeMonADE_PM/analyzer/AnalyzerIntramolecularReactions.h @@ -0,0 +1,168 @@ +/****************************************************************************** + * based on LeMonADE: https://github.com/LeMonADE-project/LeMonADE/ + * author: Toni Müller + * email: mueller-toni@ipfdd.de + * project:Phantom Modulus + *****************************************************************************/ + +#ifndef LEMONADE_PM_ANALYZER_ANALYZERINTRAMOLECULARREACTIONS_H +#define LEMONADE_PM_ANALYZER_ANALYZERINTRAMOLECULARREACTIONS_H + +#include + +#include +#include +#include +#include +#include + +/************************************************************************* + * definition of AnalyzerIntramolecularReactions class + * ***********************************************************************/ + +/** + * @file + * + * @class AnalyzerIntramolecularReactions + * + * @brief Analyzer counting the intramolecular reactions + * + * @tparam IngredientsType Ingredients class storing all system information( e.g. monomers, bonds, etc). + */ +template < class IngredientsType > class AnalyzerIntramolecularReactions : public AbstractAnalyzer +{ +private: + //! typedef for the underlying container holding the monomers + typedef typename IngredientsType::molecules_type molecules_type; + //! reference to the complete system + const IngredientsType& ingredients; + //!cotnainer holding the information about conversion nBonds nIntraBonds nBondsGel nIntraBondsGels + std::vector > data; + //! name of output file for the average is outputFilePrefix_averages.dat + std::string outputFilename; + //! save the collected data to a file + void dumpData(); + //! iterates over the structure and searches for the intramolecular reactions + void getBiggestCluster(); +public: + //! constructor + AnalyzerIntramolecularReactions(const IngredientsType& ingredients_, std::string outputFilename_); + //! destructor. does nothing + virtual ~AnalyzerIntramolecularReactions(){} + //! nothing needs to be initialized + virtual void initialize(); + //! Runs over the structure and obtains the conversion nBonds nIntraBonds nBondsGel nIntraBondsGels. + virtual bool execute(); + //! Writes the final results to file + virtual void cleanup(); +}; + +/************************************************************************* + * implementation of memebers + * ***********************************************************************/ + +/** + * @param ing reference to the object holding all information of the system + * */ +template +AnalyzerIntramolecularReactions::AnalyzerIntramolecularReactions( + const IngredientsType& ingredients_, std::string outputFilename_) +:ingredients(ingredients_) +,outputFilename(outputFilename_) +{} +//////////////////////////////////////////////////////////////////////////////// +template< class IngredientsType > +void AnalyzerIntramolecularReactions::initialize(){} + +template< class IngredientsType > +bool AnalyzerIntramolecularReactions::execute() +{ + + return true; +} +template +void AnalyzerIntramolecularReactions::cleanup() +{ + dumpData(); +} +template +void AnalyzerIntramolecularReactions::dumpData() +{ + //output for the equilibrated positions + std::stringstream commentAveragePosition; + commentAveragePosition<<"Created by AnalyzerIntramolecularReactions\n"; + commentAveragePosition<<"nTotalBonds="< +void AnalyzerIntramolecularReactions::getBiggestCluster () { + uint32_t nMolecules(0); + std::vector LargestCluster; + const typename IngredientsType::molecules_type& getMolies = ingredients.getMolecules(); + //search largest cluster: use the attribute tag for that + //at first store the initial attributes to reset them after the search + //then color the whole graph. connected parts have the same color + auto nMonomers(getMolies.size()); + std::vector Tag(nMonomers,0); + //color graph + int freeColor(1); + for (auto i=0 ; i < nMonomers;i++){ + std::vector rememberBranch; + rememberBranch.push_back(i); + if(Tag[i] == 0) { + while ( rememberBranch.size() > 0 ){ + auto ID(rememberBranch.back()); + auto color(Tag[ID]); + rememberBranch.pop_back(); + if ( color == 0){ + Tag[ID]=freeColor; + auto nLinks(getMolies.getNumLinks(ID)); + if(nLinks != 0 ){ + for(auto j=0; j < nLinks ; j++){ + auto Neighbor(getMolies.getNeighborIdx(ID,j)); + if( Tag[Neighbor] == 0 ) rememberBranch.push_back(Neighbor); + } + } + } + } + freeColor++; + } + } + freeColor--; + nMolecules=freeColor; + std::cout << "#Molecules=" << nMolecules < > ColoredGraphIDs(freeColor+1,std::vector(0)); + for (auto i=0 ; i < nMonomers;i++){ + uint32_t atti(Tag[i]); + if (atti==0 ){//this should never happen because all monomers should be covered above and colored + std::stringstream error_message; + error_message << "AnalyzerActiveChainDensity::execute(): Found monomer which is not colored! ID is " << i << "\n"; + throw std::runtime_error(error_message.str()); + } + ColoredGraphIDs[atti].push_back(i); + } + auto biggestClusterID(0); + auto biggestClusterSize(ColoredGraphIDs[biggestClusterID].size()); + for (auto i=0; i < freeColor+1 ; i++){ + std::cout << "ClusterID " << i << " cluster size " << ColoredGraphIDs[i].size() << std::endl; + if ( biggestClusterSize < ColoredGraphIDs[i].size() ){ + biggestClusterSize=ColoredGraphIDs[i].size(); + biggestClusterID=i; + } + } + std::cout << "biggest ClusterID " << biggestClusterID << " biggestClusterSize " << biggestClusterSize << std::endl; + LargestCluster=ColoredGraphIDs[biggestClusterID]; + // return LargestCluster; +} + +#endif /*LEMONADE_PM_ANALYZER_ANALYZERINTRAMOLECULARREACTIONS_H*/ + + diff --git a/projects/CMakeLists.txt b/projects/CMakeLists.txt index 5780870..738c1bd 100644 --- a/projects/CMakeLists.txt +++ b/projects/CMakeLists.txt @@ -3,4 +3,11 @@ add_executable(TendomerNetworkForceEquilibrium TendomerNetworkForceEquilibrium.cpp) -target_link_libraries(TendomerNetworkForceEquilibrium LeMonADE CommandlineParser ) \ No newline at end of file +target_link_libraries(TendomerNetworkForceEquilibrium LeMonADE CommandlineParser ) + +add_executable(TendomerNetworkExtractActivePart TendomerNetworkExtractActivePart.cpp) +target_link_libraries(TendomerNetworkExtractActivePart LeMonADE CommandlineParser ) + + +# add_executable(IntramolecularReactions IntramolecularReactions.cpp) +# target_link_libraries(IntramolecularReactions LeMonADE CommandlineParser ) \ No newline at end of file diff --git a/projects/ForceEquilibrium.cpp b/projects/ForceEquilibrium.cpp index 69fecb7..9d441e5 100644 --- a/projects/ForceEquilibrium.cpp +++ b/projects/ForceEquilibrium.cpp @@ -103,6 +103,9 @@ int main(int argc, char* argv[]){ } if (! feCurve.empty()) custom=true; + + RandomNumberGenerators rng; + rng.seedAll(); /////////////////////////////////////////////////////////////////////////////// ///end options parsing /////////////////////////////////////////////////////////////////////////////// diff --git a/projects/IntramolecularReactions.cpp b/projects/IntramolecularReactions.cpp new file mode 100644 index 0000000..7aa6fa5 --- /dev/null +++ b/projects/IntramolecularReactions.cpp @@ -0,0 +1,170 @@ +/*-------------------------------------------------------------------------------- + ooo L attice-based | + o\.|./o e xtensible | LeMonADE: An Open Source Implementation of the + o\.\|/./o Mon te-Carlo | Bond-Fluctuation-Model for Polymers +oo---0---oo A lgorithm and | + o/./|\.\o D evelopment | Copyright (C) 2013-2015 by + o/.|.\o E nvironment | LeMonADE Principal Developers (see AUTHORS) + ooo | +---------------------------------------------------------------------------------- + +This file is part of LeMonADE. + +LeMonADE 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. + +LeMonADE 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 LeMonADE. If not, see . + +--------------------------------------------------------------------------------*/ + +/****************************************************************************** + * based on LeMonADE: https://github.com/LeMonADE-project/LeMonADE/ + * author: Toni Müller + * email: mueller-toni@ipfdd.de + * project: LeMonADE-Phantom Modulus + *****************************************************************************/ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + + +int main(int argc, char* argv[]){ + try{ + /////////////////////////////////////////////////////////////////////////////// + ///parse options/// + std::string inputBFM("init.bfm"); + std::string outputData("IntramolecularReactions.dat"); + std::string inputConnection("BondCreationBreaking.dat"); + std::string feCurve(""); + double relaxationParameter(10.); + double threshold(0.5); + double stepwidth(1.0); + double minConversion(50.0); + + bool showHelp = false; + auto parser + = clara::detail::Opt( inputBFM, "inputBFM (=inconfig.bfm)" ) ["-i"]["--input" ] ("(required)Input filename of the bfm file" ).required() + | clara::detail::Opt( inputConnection, "inputConnection (=BondCreationBreaking.dat)" ) ["-d"]["--inputConnection"] ("used for the time development of the topology. " ).required() + | clara::detail::Opt( outputData, "outputData (=IntramolecularReactions.dat)" ) ["-o"]["--outputData" ] ("(optional) Output filename of the crosslink ID and the equilibrium Position.").optional() + | clara::detail::Opt( stepwidth, "stepwidth" ) ["-s"]["--stepwidth" ] ("(optional) Width for the increase in percentage. Default: 1%." ).optional() + | clara::detail::Opt( minConversion, "minConversion" ) ["-u"]["--minConversion" ] ("(optional) Minimum conversion to be read in. Default: 50%." ).optional() + | clara::detail::Opt( threshold, "threshold" ) ["-t"]["--threshold" ] ("(optional) Threshold of the average shift. Default 0.5 ." ).optional() + | clara::detail::Opt( feCurve, "feCurve (="")" ) ["-f"]["--feCurve" ] ("(optional) Force-Extension curve. Default \"\"." ).required() + | clara::detail::Opt( relaxationParameter, "relaxationParameter (=10)" ) ["-r"]["--relax" ] ("(optional) Relaxation parameter. Default 10.0 ." ).optional() + | clara::Help( showHelp ); + + auto result = parser.parse( clara::Args( argc, argv ) ); + + if( !result ) { + std::cerr << "Error in command line: " << result.errorMessage() << std::endl; + exit(1); + }else if(showHelp == true){ + std::cout << "Simulator to connect linear chains with single monomers of certain functionality"<< std::endl; + parser.writeToStream(std::cout); + exit(0); + }else{ + std::cout << "outputData : " << outputData << std::endl; + std::cout << "inputBFM : " << inputBFM << std::endl; + std::cout << "inputConnection : " << inputConnection << std::endl; + std::cout << "stepwidth : " << stepwidth << std::endl; + std::cout << "minConversion : " << minConversion << std::endl; + std::cout << "threshold : " << threshold << std::endl; + std::cout << "feCurve : " << feCurve << std::endl; + } + + /////////////////////////////////////////////////////////////////////////////// + ///end options parsing + /////////////////////////////////////////////////////////////////////////////// + //Read in th last Config + typedef LOKI_TYPELIST_3(FeatureMoleculesIOUnsaveCheck, FeatureLabel, FeatureReactiveBonds) Features; + typedef ConfigureSystem Config; + typedef Ingredients Ing; + Ing myIngredients; + + TaskManager taskmanager; + + taskmanager.addUpdater( new UpdaterReadBfmFile(inputBFM,myIngredients, UpdaterReadBfmFile::READ_LAST_CONFIG_SAVE),0); + + //initialize and run + taskmanager.initialize(); + taskmanager.run(1); + taskmanager.cleanup(); + std::cout << "Read in conformation and go on to bring it into equilibrium forces..." < Config2; + typedef Ingredients Ing2; + Ing2 myIngredients2; + + myIngredients2.setBoxX(myIngredients.getBoxX()); + myIngredients2.setBoxY(myIngredients.getBoxY()); + myIngredients2.setBoxZ(myIngredients.getBoxZ()); + myIngredients2.setPeriodicX(myIngredients.isPeriodicX()); + myIngredients2.setPeriodicY(myIngredients.isPeriodicY()); + myIngredients2.setPeriodicZ(myIngredients.isPeriodicZ()); + myIngredients2.modifyMolecules().resize(myIngredients.getMolecules().size()); + myIngredients2.modifyMolecules().setAge(myIngredients.getMolecules().getAge()); + + myIngredients2.setNumTendomers (myIngredients.getNumTendomers()); + myIngredients2.setNumCrossLinkers (myIngredients.getNumCrossLinkers()); + myIngredients2.setNumMonomersPerChain (myIngredients.getNumMonomersPerChain()); + myIngredients2.setNumLabelsPerTendomerArm(myIngredients.getNumLabelsPerTendomerArm()); + + for(size_t i = 0; i< myIngredients.getMolecules().size();i++){ + myIngredients2.modifyMolecules()[i].modifyVector3D()=myIngredients.getMolecules()[i].getVector3D(); + myIngredients2.modifyMolecules()[i].setReactive(myIngredients.getMolecules()[i].isReactive()); + myIngredients2.modifyMolecules()[i].setNumMaxLinks(myIngredients.getMolecules()[i].getNumMaxLinks()); + for (size_t j = 0 ; j < myIngredients.getMolecules().getNumLinks(i);j++){ + uint32_t neighbor(myIngredients.getMolecules().getNeighborIdx(i,j)); + if( ! myIngredients2.getMolecules().areConnected(i,neighbor) ) + myIngredients2.modifyMolecules().connect(i,neighbor); + } + } + myIngredients2.synchronize(); + + TaskManager taskmanager2; + //read bonds and positions stepwise + taskmanager2.addUpdater( new UpdaterReadCrosslinkConnectionsTendomer(myIngredients2, inputConnection, stepwidth, minConversion) ); + taskmanager2.addAnalyzer(new AnalyzerIntramolecularReactions(myIngredients2, outputData)); + //initialize and run + taskmanager2.initialize(); + taskmanager2.run(); + taskmanager2.cleanup(); + + } + catch(std::exception& e){ + std::cerr<<"Error:\n" + <. + +--------------------------------------------------------------------------------*/ + +/****************************************************************************** + * based on LeMonADE: https://github.com/LeMonADE-project/LeMonADE/ + * author: Toni Müller + * email: mueller-toni@ipfdd.de + * project: LeMonADE-Phantom Modulus + *****************************************************************************/ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + + +int main(int argc, char* argv[]){ + try{ + /////////////////////////////////////////////////////////////////////////////// + ///parse options/// + std::string inputBFM("init.bfm"); + std::string outputBFM("Config.bfm.dat"); + std::string inputConnection("BondCreationBreaking.dat"); + std::string activeComponent("active_00001.dat"); + bool showHelp = false; + auto parser + = clara::detail::Opt( inputBFM, "inputBFM (=inconfig.bfm)" ) ["-i"]["--input" ] ("(required)Input filename of the bfm file" ).required() + | clara::detail::Opt( inputConnection, "inputConnection (=BondCreationBreaking.dat)" ) ["-d"]["--inputConnection" ] ("used for the time development of the topology. " ).required() + | clara::detail::Opt( activeComponent, "activeComponents (=active_00001.dat)" ) ["-a"]["--activeComponents"] ("sets the active components . " ).required() + | clara::detail::Opt( outputBFM, "outputBFM (=Config.bfm)" ) ["-o"]["--outputBFM" ] ("Output filename for the active material of the tendomer network.") + | clara::Help( showHelp ); + + auto result = parser.parse( clara::Args( argc, argv ) ); + + if( !result ) { + std::cerr << "Error in command line: " << result.errorMessage() << std::endl; + exit(1); + }else if(showHelp == true){ + std::cout << "Analyzer taking a bond table and a table specifying the activity of an object and writes the active part of the tendoemr network."<< std::endl; + std::cout << "Important: input file for the connections and the active material must fit to each other!!!"<< std::endl; + parser.writeToStream(std::cout); + exit(0); + }else{ + std::cout << "outputBFM : " << outputBFM << std::endl; + std::cout << "inputBFM : " << inputBFM << std::endl; + std::cout << "inputConnection : " << inputConnection << std::endl; + std::cout << "activeComponent : " << activeComponent << std::endl; + } + RandomNumberGenerators rng; + rng.seedAll(); + /////////////////////////////////////////////////////////////////////////////// + ///end options parsing + /////////////////////////////////////////////////////////////////////////////// + //Read in th last Config + typedef LOKI_TYPELIST_4(FeatureMoleculesIOUnsaveCheck, FeatureLabel, FeatureReactiveBonds, FeatureAttributes<>) Features; + typedef ConfigureSystem Config; + typedef Ingredients Ing; + Ing myIngredients; + + TaskManager taskmanager; + + taskmanager.addUpdater( new UpdaterReadBfmFile(inputBFM,myIngredients, UpdaterReadBfmFile::READ_LAST_CONFIG_SAVE),0); + taskmanager.addUpdater( new UpdaterReadCrosslinkConnectionsTendomer(myIngredients, inputConnection, 0., 1.0) ); + + //initialize and run + taskmanager.initialize(); + taskmanager.run(1); + taskmanager.cleanup(); + std::cout << "Read in conformation and go on to bring it into equilibrium forces..." < activeObject; + std::ifstream in(activeComponent); + std::string line; + + auto nCrossLinks(myIngredients.getNumCrossLinkers()); + auto nChains(myIngredients.getNumTendomers()); + auto nSegments(myIngredients.getNumMonomersPerChain()*2); + auto nChainMonomers(nChains*nSegments); + auto objectID(0); + auto nActiveCrossLinks(0); + auto nActiveTendomers(0); + std::cout <<"Filestart:\n" ; + while (in.good() && ! in.eof() ){ + getline(in,line); + std::stringstream ss; + uint32_t activeTag; + ss << line; + std::cout << line <<"\n"; + if (! line.empty()) { + ss >>activeTag; + auto tmpAttribute(0); + if(objectID < nCrossLinks ){ + auto IdX(nChainMonomers+objectID); + std::cout << "OId=" << objectID << " IdX=" << IdX << std::endl; + if (activeTag == 2 ){ + tmpAttribute=1; + nActiveCrossLinks++; + } + myIngredients.modifyMolecules()[nChainMonomers+objectID].setAttributeTag(tmpAttribute); + }else{ + auto IdCStart((objectID-nCrossLinks)*nSegments); + auto IdCEnd( (objectID-nCrossLinks+1)*nSegments-1); + std::cout << "OId=" << objectID << " IdC=" << IdCStart << "-" << IdCEnd << std::endl; + if (activeTag == 2 ) { + nActiveTendomers++; + tmpAttribute=1; + } + for (auto i =IdCStart ; i <= IdCEnd; i++ ) + myIngredients.modifyMolecules()[i].setAttributeTag(tmpAttribute); + } + objectID++; + } + } + std::cout <<"Fileend:\n" ; + // for() + myIngredients.setNumTendomers (nActiveTendomers); + myIngredients.setNumCrossLinkers (nActiveCrossLinks); + myIngredients.setNumMonomersPerChain (myIngredients.getNumMonomersPerChain()); + myIngredients.setNumLabelsPerTendomerArm(myIngredients.getNumLabelsPerTendomerArm()); + myIngredients.synchronize(); + + + MonomerGroup subgroup(myIngredients.getMolecules()); + subgroup.clear(); + hasThisType<1> predicate; + for(size_t n=0;n(outputBFM, myIngredients, 1) ); + //initialize and run + taskmanager2.initialize(); + taskmanager2.run(1); + taskmanager2.cleanup(); + + // AnalyzerWriteBfmFileSubGroup > writer(outputBFM, myIngredients, 1, hasThisType<1>()); + // writer.initialize(); + + // TaskManager taskmanager2; + // taskmanager2.addAnalyzer( new AnalyzerWriteBfmFileSubGroup >(outputBFM, myIngredients, 1, hasThisType<1>()) ); + + // //initialize and run + // taskmanager2.initialize(); + // taskmanager2.run(1); + // // taskmanager2.cleanup(); + + } + catch(std::exception& e){ + std::cerr<<"Error:\n" + <. #include #include #include +#include #include @@ -61,21 +62,18 @@ int main(int argc, char* argv[]){ std::string inputBFM("init.bfm"); std::string outputDataPos("CrosslinkPosition.dat"); std::string outputDataDist("ChainExtensionDistribution.dat"); - std::string inputConnection("BondCreationBreaking.dat"); + // std::string inputConnection("BondCreationBreaking.dat"); std::string feCurve(""); double relaxationParameter(10.); double threshold(0.5); - double stepwidth(1.0); - double minConversion(50.0); + // double stepwidth(1.0); + // double minConversion(50.0); bool showHelp = false; auto parser = clara::detail::Opt( inputBFM, "inputBFM (=inconfig.bfm)" ) ["-i"]["--input" ] ("(required)Input filename of the bfm file" ).required() - | clara::detail::Opt( inputConnection, "inputConnection (=BondCreationBreaking.dat)" ) ["-d"]["--inputConnection"] ("used for the time development of the topology. " ).required() | clara::detail::Opt( outputDataPos, "outputDataPos (=CrosslinkPosition.dat)" ) ["-o"]["--outputPos" ] ("(optional) Output filename of the crosslink ID and the equilibrium Position.").optional() | clara::detail::Opt( outputDataDist, "outputDataDist (=ChainExtensionDistribution.dat)") ["-c"]["--outputDist" ] ("(optional) Output filename of the chain extension distribution." ).optional() - | clara::detail::Opt( stepwidth, "stepwidth" ) ["-s"]["--stepwidth" ] ("(optional) Width for the increase in percentage. Default: 1%." ).optional() - | clara::detail::Opt( minConversion, "minConversion" ) ["-u"]["--minConversion" ] ("(optional) Minimum conversion to be read in. Default: 50%." ).optional() | clara::detail::Opt( threshold, "threshold" ) ["-t"]["--threshold" ] ("(optional) Threshold of the average shift. Default 0.5 ." ).optional() | clara::detail::Opt( feCurve, "feCurve (="")" ) ["-f"]["--feCurve" ] ("(optional) Force-Extension curve. Default \"\"." ).required() | clara::detail::Opt( relaxationParameter, "relaxationParameter (=10)" ) ["-r"]["--relax" ] ("(optional) Relaxation parameter. Default 10.0 ." ).optional() @@ -94,13 +92,11 @@ int main(int argc, char* argv[]){ std::cout << "outputData : " << outputDataPos << std::endl; std::cout << "outputDataDist : " << outputDataDist << std::endl; std::cout << "inputBFM : " << inputBFM << std::endl; - std::cout << "inputConnection : " << inputConnection << std::endl; - std::cout << "stepwidth : " << stepwidth << std::endl; - std::cout << "minConversion : " << minConversion << std::endl; std::cout << "threshold : " << threshold << std::endl; std::cout << "feCurve : " << feCurve << std::endl; } - + RandomNumberGenerators rng; + rng.seedAll(); /////////////////////////////////////////////////////////////////////////////// ///end options parsing /////////////////////////////////////////////////////////////////////////////// @@ -134,12 +130,6 @@ int main(int argc, char* argv[]){ myIngredients2.modifyMolecules().resize(myIngredients.getMolecules().size()); myIngredients2.modifyMolecules().setAge(myIngredients.getMolecules().getAge()); - // myIngredients2.setNumOfChains (myIngredients.getNumOfChains()); - // myIngredients2.setNumOfCrosslinks (myIngredients.getNumOfCrosslinks()); - // myIngredients2.setNumOfMonomersPerChain (myIngredients.getNumOfMonomersPerChain()); - // myIngredients2.setNumOfMonomersPerCrosslink(myIngredients.getNumOfMonomersPerCrosslink()); - // myIngredients2.setFunctionality (myIngredients.getFunctionality()); - myIngredients2.setNumTendomers (myIngredients.getNumTendomers()); myIngredients2.setNumCrossLinkers (myIngredients.getNumCrossLinkers()); myIngredients2.setNumMonomersPerChain (myIngredients.getNumMonomersPerChain()); @@ -159,7 +149,6 @@ int main(int argc, char* argv[]){ TaskManager taskmanager2; //read bonds and positions stepwise - taskmanager2.addUpdater( new UpdaterReadCrosslinkConnectionsTendomer(myIngredients2, inputConnection, stepwidth, minConversion) ); auto updater = new UpdaterForceBalancedPositionTendomer(myIngredients2, threshold) ; updater->setFilename(feCurve); updater->setRelaxationParameter(relaxationParameter); diff --git a/projects/TendomerNetworkForceEquilibriumConversionSeries.cpp b/projects/TendomerNetworkForceEquilibriumConversionSeries.cpp new file mode 100644 index 0000000..58a734b --- /dev/null +++ b/projects/TendomerNetworkForceEquilibriumConversionSeries.cpp @@ -0,0 +1,186 @@ +/*-------------------------------------------------------------------------------- + ooo L attice-based | + o\.|./o e xtensible | LeMonADE: An Open Source Implementation of the + o\.\|/./o Mon te-Carlo | Bond-Fluctuation-Model for Polymers +oo---0---oo A lgorithm and | + o/./|\.\o D evelopment | Copyright (C) 2013-2015 by + o/.|.\o E nvironment | LeMonADE Principal Developers (see AUTHORS) + ooo | +---------------------------------------------------------------------------------- + +This file is part of LeMonADE. + +LeMonADE 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. + +LeMonADE 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 LeMonADE. If not, see . + +--------------------------------------------------------------------------------*/ + +/****************************************************************************** + * based on LeMonADE: https://github.com/LeMonADE-project/LeMonADE/ + * author: Toni Müller + * email: mueller-toni@ipfdd.de + * project: LeMonADE-Phantom Modulus + *****************************************************************************/ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + + +int main(int argc, char* argv[]){ + try{ + /////////////////////////////////////////////////////////////////////////////// + ///parse options/// + std::string inputBFM("init.bfm"); + std::string outputDataPos("CrosslinkPosition.dat"); + std::string outputDataDist("ChainExtensionDistribution.dat"); + std::string inputConnection("BondCreationBreaking.dat"); + std::string feCurve(""); + double relaxationParameter(10.); + double threshold(0.5); + double stepwidth(1.0); + double minConversion(50.0); + + bool showHelp = false; + auto parser + = clara::detail::Opt( inputBFM, "inputBFM (=inconfig.bfm)" ) ["-i"]["--input" ] ("(required)Input filename of the bfm file" ).required() + | clara::detail::Opt( inputConnection, "inputConnection (=BondCreationBreaking.dat)" ) ["-d"]["--inputConnection"] ("used for the time development of the topology. " ).required() + | clara::detail::Opt( outputDataPos, "outputDataPos (=CrosslinkPosition.dat)" ) ["-o"]["--outputPos" ] ("(optional) Output filename of the crosslink ID and the equilibrium Position.").optional() + | clara::detail::Opt( outputDataDist, "outputDataDist (=ChainExtensionDistribution.dat)") ["-c"]["--outputDist" ] ("(optional) Output filename of the chain extension distribution." ).optional() + | clara::detail::Opt( stepwidth, "stepwidth" ) ["-s"]["--stepwidth" ] ("(optional) Width for the increase in percentage. Default: 1%." ).optional() + | clara::detail::Opt( minConversion, "minConversion" ) ["-u"]["--minConversion" ] ("(optional) Minimum conversion to be read in. Default: 50%." ).optional() + | clara::detail::Opt( threshold, "threshold" ) ["-t"]["--threshold" ] ("(optional) Threshold of the average shift. Default 0.5 ." ).optional() + | clara::detail::Opt( feCurve, "feCurve (="")" ) ["-f"]["--feCurve" ] ("(optional) Force-Extension curve. Default \"\"." ).required() + | clara::detail::Opt( relaxationParameter, "relaxationParameter (=10)" ) ["-r"]["--relax" ] ("(optional) Relaxation parameter. Default 10.0 ." ).optional() + | clara::Help( showHelp ); + + auto result = parser.parse( clara::Args( argc, argv ) ); + + if( !result ) { + std::cerr << "Error in command line: " << result.errorMessage() << std::endl; + exit(1); + }else if(showHelp == true){ + std::cout << "Simulator to connect linear chains with single monomers of certain functionality"<< std::endl; + parser.writeToStream(std::cout); + exit(0); + }else{ + std::cout << "outputData : " << outputDataPos << std::endl; + std::cout << "outputDataDist : " << outputDataDist << std::endl; + std::cout << "inputBFM : " << inputBFM << std::endl; + std::cout << "inputConnection : " << inputConnection << std::endl; + std::cout << "stepwidth : " << stepwidth << std::endl; + std::cout << "minConversion : " << minConversion << std::endl; + std::cout << "threshold : " << threshold << std::endl; + std::cout << "feCurve : " << feCurve << std::endl; + } + RandomNumberGenerators rng; + rng.seedAll(); + /////////////////////////////////////////////////////////////////////////////// + ///end options parsing + /////////////////////////////////////////////////////////////////////////////// + //Read in th last Config + typedef LOKI_TYPELIST_3(FeatureMoleculesIOUnsaveCheck, FeatureLabel, FeatureReactiveBonds) Features; + typedef ConfigureSystem Config; + typedef Ingredients Ing; + Ing myIngredients; + + TaskManager taskmanager; + + taskmanager.addUpdater( new UpdaterReadBfmFile(inputBFM,myIngredients, UpdaterReadBfmFile::READ_LAST_CONFIG_SAVE),0); + + //initialize and run + taskmanager.initialize(); + taskmanager.run(1); + taskmanager.cleanup(); + std::cout << "Read in conformation and go on to bring it into equilibrium forces..." < Config2; + typedef Ingredients Ing2; + Ing2 myIngredients2; + + myIngredients2.setBoxX(myIngredients.getBoxX()); + myIngredients2.setBoxY(myIngredients.getBoxY()); + myIngredients2.setBoxZ(myIngredients.getBoxZ()); + myIngredients2.setPeriodicX(myIngredients.isPeriodicX()); + myIngredients2.setPeriodicY(myIngredients.isPeriodicY()); + myIngredients2.setPeriodicZ(myIngredients.isPeriodicZ()); + myIngredients2.modifyMolecules().resize(myIngredients.getMolecules().size()); + myIngredients2.modifyMolecules().setAge(myIngredients.getMolecules().getAge()); + + // myIngredients2.setNumOfChains (myIngredients.getNumOfChains()); + // myIngredients2.setNumOfCrosslinks (myIngredients.getNumOfCrosslinks()); + // myIngredients2.setNumOfMonomersPerChain (myIngredients.getNumOfMonomersPerChain()); + // myIngredients2.setNumOfMonomersPerCrosslink(myIngredients.getNumOfMonomersPerCrosslink()); + // myIngredients2.setFunctionality (myIngredients.getFunctionality()); + + myIngredients2.setNumTendomers (myIngredients.getNumTendomers()); + myIngredients2.setNumCrossLinkers (myIngredients.getNumCrossLinkers()); + myIngredients2.setNumMonomersPerChain (myIngredients.getNumMonomersPerChain()); + myIngredients2.setNumLabelsPerTendomerArm(myIngredients.getNumLabelsPerTendomerArm()); + + for(size_t i = 0; i< myIngredients.getMolecules().size();i++){ + myIngredients2.modifyMolecules()[i].modifyVector3D()=myIngredients.getMolecules()[i].getVector3D(); + myIngredients2.modifyMolecules()[i].setReactive(myIngredients.getMolecules()[i].isReactive()); + myIngredients2.modifyMolecules()[i].setNumMaxLinks(myIngredients.getMolecules()[i].getNumMaxLinks()); + for (size_t j = 0 ; j < myIngredients.getMolecules().getNumLinks(i);j++){ + uint32_t neighbor(myIngredients.getMolecules().getNeighborIdx(i,j)); + if( ! myIngredients2.getMolecules().areConnected(i,neighbor) ) + myIngredients2.modifyMolecules().connect(i,neighbor); + } + } + myIngredients2.synchronize(); + + TaskManager taskmanager2; + //read bonds and positions stepwise + taskmanager2.addUpdater( new UpdaterReadCrosslinkConnectionsTendomer(myIngredients2, inputConnection, stepwidth, minConversion) ); + auto updater = new UpdaterForceBalancedPositionTendomer(myIngredients2, threshold) ; + updater->setFilename(feCurve); + updater->setRelaxationParameter(relaxationParameter); + // auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; + taskmanager2.addUpdater( updater ); + taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,outputDataPos, outputDataDist)); + //initialize and run + taskmanager2.initialize(); + taskmanager2.run(); + taskmanager2.cleanup(); + + } + catch(std::exception& e){ + std::cerr<<"Error:\n" + < Date: Fri, 4 Jun 2021 09:19:56 +0200 Subject: [PATCH 06/70] bugfix --- projects/TendomerNetworkExtractActivePart.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/projects/TendomerNetworkExtractActivePart.cpp b/projects/TendomerNetworkExtractActivePart.cpp index b22fa6b..d8535db 100644 --- a/projects/TendomerNetworkExtractActivePart.cpp +++ b/projects/TendomerNetworkExtractActivePart.cpp @@ -192,10 +192,11 @@ int main(int argc, char* argv[]){ TaskManager taskmanager2; taskmanager2.addAnalyzer( new AnalyzerWriteBfmFile(outputBFM, myIngredients, 1) ); //initialize and run - taskmanager2.initialize(); - taskmanager2.run(1); - taskmanager2.cleanup(); - + if ( nActiveTendomers > 0 ){ + taskmanager2.initialize(); + taskmanager2.run(1); + taskmanager2.cleanup(); + } // AnalyzerWriteBfmFileSubGroup > writer(outputBFM, myIngredients, 1, hasThisType<1>()); // writer.initialize(); From 27debe9c4716172503a12041301770d36e16ccd7 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Fri, 4 Jun 2021 10:31:17 +0200 Subject: [PATCH 07/70] comemnt out stdout --- projects/TendomerNetworkExtractActivePart.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/TendomerNetworkExtractActivePart.cpp b/projects/TendomerNetworkExtractActivePart.cpp index d8535db..0593303 100644 --- a/projects/TendomerNetworkExtractActivePart.cpp +++ b/projects/TendomerNetworkExtractActivePart.cpp @@ -129,13 +129,13 @@ int main(int argc, char* argv[]){ std::stringstream ss; uint32_t activeTag; ss << line; - std::cout << line <<"\n"; + // std::cout << line <<"\n"; if (! line.empty()) { ss >>activeTag; auto tmpAttribute(0); if(objectID < nCrossLinks ){ auto IdX(nChainMonomers+objectID); - std::cout << "OId=" << objectID << " IdX=" << IdX << std::endl; + // std::cout << "OId=" << objectID << " IdX=" << IdX << std::endl; if (activeTag == 2 ){ tmpAttribute=1; nActiveCrossLinks++; @@ -144,7 +144,7 @@ int main(int argc, char* argv[]){ }else{ auto IdCStart((objectID-nCrossLinks)*nSegments); auto IdCEnd( (objectID-nCrossLinks+1)*nSegments-1); - std::cout << "OId=" << objectID << " IdC=" << IdCStart << "-" << IdCEnd << std::endl; + // std::cout << "OId=" << objectID << " IdC=" << IdCStart << "-" << IdCEnd << std::endl; if (activeTag == 2 ) { nActiveTendomers++; tmpAttribute=1; From 642b2f6dbfd340aca6638edbff231a8b45778c9c Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Wed, 9 Jun 2021 13:39:00 +0200 Subject: [PATCH 08/70] TendomerNetworkWritePartialConnectedNetwork: Erases all reversible bonds and creates only these in the given bond table file --- projects/CMakeLists.txt | 3 + ...merNetworkWritePartialConnectedNetwork.cpp | 121 ++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 projects/TendomerNetworkWritePartialConnectedNetwork.cpp diff --git a/projects/CMakeLists.txt b/projects/CMakeLists.txt index 738c1bd..74c7ce4 100644 --- a/projects/CMakeLists.txt +++ b/projects/CMakeLists.txt @@ -9,5 +9,8 @@ add_executable(TendomerNetworkExtractActivePart TendomerNetworkExtractActivePart target_link_libraries(TendomerNetworkExtractActivePart LeMonADE CommandlineParser ) +add_executable(TendomerNetworkWritePartialConnectedNetwork TendomerNetworkWritePartialConnectedNetwork.cpp) +target_link_libraries(TendomerNetworkWritePartialConnectedNetwork LeMonADE CommandlineParser ) + # add_executable(IntramolecularReactions IntramolecularReactions.cpp) # target_link_libraries(IntramolecularReactions LeMonADE CommandlineParser ) \ No newline at end of file diff --git a/projects/TendomerNetworkWritePartialConnectedNetwork.cpp b/projects/TendomerNetworkWritePartialConnectedNetwork.cpp new file mode 100644 index 0000000..bcbc61b --- /dev/null +++ b/projects/TendomerNetworkWritePartialConnectedNetwork.cpp @@ -0,0 +1,121 @@ +/*-------------------------------------------------------------------------------- + ooo L attice-based | + o\.|./o e xtensible | LeMonADE: An Open Source Implementation of the + o\.\|/./o Mon te-Carlo | Bond-Fluctuation-Model for Polymers +oo---0---oo A lgorithm and | + o/./|\.\o D evelopment | Copyright (C) 2013-2015 by + o/.|.\o E nvironment | LeMonADE Principal Developers (see AUTHORS) + ooo | +---------------------------------------------------------------------------------- + +This file is part of LeMonADE. + +LeMonADE 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. + +LeMonADE 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 LeMonADE. If not, see . + +--------------------------------------------------------------------------------*/ + +/****************************************************************************** + * based on LeMonADE: https://github.com/LeMonADE-project/LeMonADE/ + * author: Toni Müller + * email: mueller-toni@ipfdd.de + * project: LeMonADE-Phantom Modulus + *****************************************************************************/ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + + +int main(int argc, char* argv[]){ + try{ + /////////////////////////////////////////////////////////////////////////////// + ///parse options/// + std::string inputBFM("init.bfm"); + std::string outputBFM("Config.bfm.dat"); + std::string inputConnection("BondCreationBreaking.dat"); + bool showHelp = false; + auto parser + = clara::detail::Opt( inputBFM, "inputBFM (=inconfig.bfm)" ) ["-i"]["--input" ] ("(required)Input filename of the bfm file" ).required() + | clara::detail::Opt( inputConnection, "inputConnection (=BondCreationBreaking.dat)" ) ["-d"]["--inputConnection" ] ("used for the time development of the topology. " ).required() + | clara::detail::Opt( outputBFM, "outputBFM (=Config.bfm)" ) ["-o"]["--outputBFM" ] ("Output filename for the active material of the tendomer network.") + | clara::Help( showHelp ); + + auto result = parser.parse( clara::Args( argc, argv ) ); + + if( !result ) { + std::cerr << "Error in command line: " << result.errorMessage() << std::endl; + exit(1); + }else if(showHelp == true){ + std::cout << "Analyzer taking a bond table and a table specifying the activity of an object and writes the active part of the tendoemr network."<< std::endl; + std::cout << "Important: input file for the connections and the active material must fit to each other!!!"<< std::endl; + parser.writeToStream(std::cout); + exit(0); + }else{ + std::cout << "outputBFM : " << outputBFM << std::endl; + std::cout << "inputBFM : " << inputBFM << std::endl; + std::cout << "inputConnection : " << inputConnection << std::endl; + } + RandomNumberGenerators rng; + rng.seedAll(); + /////////////////////////////////////////////////////////////////////////////// + ///end options parsing + /////////////////////////////////////////////////////////////////////////////// + //Read in th last Config + typedef LOKI_TYPELIST_4(FeatureMoleculesIOUnsaveCheck, FeatureLabel, FeatureReactiveBonds, FeatureAttributes<>) Features; + typedef ConfigureSystem Config; + typedef Ingredients Ing; + Ing myIngredients; + + TaskManager taskmanager; + + taskmanager.addUpdater( new UpdaterReadBfmFile(inputBFM,myIngredients, UpdaterReadBfmFile::READ_LAST_CONFIG_SAVE),0); + taskmanager.addUpdater( new UpdaterReadCrosslinkConnectionsTendomer(myIngredients, inputConnection, 0., 1.0) ); + taskmanager.addAnalyzer( new AnalyzerWriteBfmFile(outputBFM, myIngredients, 1) ); + //initialize and run + taskmanager.initialize(); + taskmanager.run(1); + taskmanager.cleanup(); + std::cout << "Read in conformation and go on to bring it into equilibrium forces..." < Date: Thu, 10 Jun 2021 09:56:57 +0200 Subject: [PATCH 09/70] bugfix for non converging system --- .../updater/UpdaterForceBalancedPositionTendomer.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/LeMonADE_PM/updater/UpdaterForceBalancedPositionTendomer.h b/include/LeMonADE_PM/updater/UpdaterForceBalancedPositionTendomer.h index 0df7f26..25680ea 100644 --- a/include/LeMonADE_PM/updater/UpdaterForceBalancedPositionTendomer.h +++ b/include/LeMonADE_PM/updater/UpdaterForceBalancedPositionTendomer.h @@ -68,6 +68,7 @@ class UpdaterForceBalancedPositionTendomer:public AbstractUpdater template bool UpdaterForceBalancedPositionTendomer::execute(){ std::cout << "UpdaterForceBalancedPositionTendomer::execute(): Start equilibration" <::execute(){ } if( NSuccessfulMoves>0 ){ avShift/=(NSuccessfulMoves); - }else + counter=0; + }else { avShift=threshold*1.1; + counter++; + } + if (counter > 10 ){break;} ing.modifyMolecules().setAge(ing.getMolecules().getAge()+1); if (ing.getMolecules().getAge() %1000 == 0 ){ std::cout << "MCS: " << ing.getMolecules().getAge() << " and average shift: " << avShift << std::endl; From 3ea9ae1f65cdaa5704edcb08c6fd0beae38d172f Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Thu, 10 Jun 2021 10:02:54 +0200 Subject: [PATCH 10/70] add possibility to chagne the relaxation factor --- .../updater/UpdaterForceBalancedPositionTendomer.h | 8 +++++--- projects/TendomerNetworkForceEquilibrium.cpp | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/LeMonADE_PM/updater/UpdaterForceBalancedPositionTendomer.h b/include/LeMonADE_PM/updater/UpdaterForceBalancedPositionTendomer.h index 25680ea..974ab5c 100644 --- a/include/LeMonADE_PM/updater/UpdaterForceBalancedPositionTendomer.h +++ b/include/LeMonADE_PM/updater/UpdaterForceBalancedPositionTendomer.h @@ -40,8 +40,8 @@ class UpdaterForceBalancedPositionTendomer:public AbstractUpdater { public: //! constructor for UpdaterForceBalancedPositionTendomer - UpdaterForceBalancedPositionTendomer(IngredientsType& ing_, double threshold_ ): - ing(ing_),threshold(threshold_){}; + UpdaterForceBalancedPositionTendomer(IngredientsType& ing_, double threshold_, double factor_=0.995 ): + ing(ing_),threshold(threshold_),factor(factor_){}; virtual void initialize(){relaxationParameter=move.getRelaxationParameter();}// init(move);}; bool execute(); @@ -57,6 +57,8 @@ class UpdaterForceBalancedPositionTendomer:public AbstractUpdater double threshold; double relaxationParameter; + + double factor; //! move to equilibrate the cross links by force equilibrium moveType move; @@ -99,7 +101,7 @@ bool UpdaterForceBalancedPositionTendomer::execute(){ ing.modifyMolecules().setAge(ing.getMolecules().getAge()+1); if (ing.getMolecules().getAge() %1000 == 0 ){ std::cout << "MCS: " << ing.getMolecules().getAge() << " and average shift: " << avShift << std::endl; - setRelaxationParameter(move.getRelaxationParameter()*0.995 ); + setRelaxationParameter(move.getRelaxationParameter()*factor ); } } std::cout << "Finish equilibration with average shift per cross link < " << avShift << " after " << ing.getMolecules().getAge()-StartMCS <(myIngredients2, threshold) ; + auto updater = new UpdaterForceBalancedPositionTendomer(myIngredients2, threshold, factor) ; updater->setFilename(feCurve); updater->setRelaxationParameter(relaxationParameter); // auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; From 3772c99c5f579c6d8f6ff2bec8287351a34f773b Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Fri, 11 Jun 2021 11:52:01 +0200 Subject: [PATCH 11/70] include the standard force equilibrium into the compilation again --- projects/CMakeLists.txt | 4 ++-- projects/ForceEquilibrium.cpp | 28 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/projects/CMakeLists.txt b/projects/CMakeLists.txt index 74c7ce4..b7cbc52 100644 --- a/projects/CMakeLists.txt +++ b/projects/CMakeLists.txt @@ -1,5 +1,5 @@ -# add_executable(ForceEquilibrium ForceEquilibrium.cpp) -# target_link_libraries(ForceEquilibrium LeMonADE CommandlineParser ) +add_executable(ForceEquilibrium ForceEquilibrium.cpp) +target_link_libraries(ForceEquilibrium LeMonADE CommandlineParser ) add_executable(TendomerNetworkForceEquilibrium TendomerNetworkForceEquilibrium.cpp) diff --git a/projects/ForceEquilibrium.cpp b/projects/ForceEquilibrium.cpp index 9d441e5..a7142b0 100644 --- a/projects/ForceEquilibrium.cpp +++ b/projects/ForceEquilibrium.cpp @@ -62,12 +62,12 @@ int main(int argc, char* argv[]){ std::string outputDataPos("CrosslinkPosition.dat"); std::string outputDataDist("ChainExtensionDistribution.dat"); std::string inputConnection("BondCreationBreaking.dat"); - std::string feCurve(""); - double relaxationParameter(10.); + // std::string feCurve(""); + // double relaxationParameter(10.); double threshold(0.5); double stepwidth(1.0); double minConversion(50.0); - bool custom(false); + // bool custom(true); bool showHelp = false; auto parser @@ -78,8 +78,8 @@ int main(int argc, char* argv[]){ | clara::detail::Opt( stepwidth, "stepwidth" ) ["-s"]["--stepwidth" ] ("(optional) Width for the increase in percentage. Default: 1%." ).optional() | clara::detail::Opt( minConversion, "minConversion" ) ["-u"]["--minConversion" ] ("(optional) Minimum conversion to be read in. Default: 50%." ).optional() | clara::detail::Opt( threshold, "threshold" ) ["-t"]["--threshold" ] ("(optional) Threshold of the average shift. Default 0.5 ." ).optional() - | clara::detail::Opt( feCurve, "feCurve (="")" ) ["-f"]["--feCurve" ] ("(optional) Force-Extension curve. Default \"\"." ).optional() - | clara::detail::Opt( relaxationParameter, "relaxationParameter (=10)" ) ["-r"]["--relax" ] ("(optional) Relaxation parameter. Default 10.0 ." ).optional() + // | clara::detail::Opt( feCurve, "feCurve (="")" ) ["-f"]["--feCurve" ] ("(optional) Force-Extension curve. Default \"\"." ).optional() + // | clara::detail::Opt( relaxationParameter, "relaxationParameter (=10)" ) ["-r"]["--relax" ] ("(optional) Relaxation parameter. Default 10.0 ." ).optional() | clara::Help( showHelp ); auto result = parser.parse( clara::Args( argc, argv ) ); @@ -99,9 +99,9 @@ int main(int argc, char* argv[]){ std::cout << "stepwidth : " << stepwidth << std::endl; std::cout << "minConversion : " << minConversion << std::endl; std::cout << "threshold : " << threshold << std::endl; - std::cout << "feCurve : " << feCurve << std::endl; + // std::cout << "feCurve : " << feCurve << std::endl; } - if (! feCurve.empty()) custom=true; + // if (! feCurve.empty()) custom=false; RandomNumberGenerators rng; @@ -159,14 +159,14 @@ int main(int argc, char* argv[]){ TaskManager taskmanager2; //read bonds and positions stepwise taskmanager2.addUpdater( new UpdaterReadCrosslinkConnections(myIngredients2, inputConnection, stepwidth, minConversion) ); - if (custom) + // if (custom) taskmanager2.addUpdater( new UpdaterForceBalancedPosition(myIngredients2, threshold) ); - else { - auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; - updater->setFilename(feCurve); - updater->setRelaxationParameter(relaxationParameter); - taskmanager2.addUpdater( updater ); - } + // else { + // auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; + // updater->setFilename(feCurve); + // updater->setRelaxationParameter(relaxationParameter); + // taskmanager2.addUpdater( updater ); + // } taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,outputDataPos, outputDataDist)); //initialize and run taskmanager2.initialize(); From d8186b1d104bb2cd975823e57790b0396d0cea19 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Wed, 16 Jun 2021 10:43:20 +0200 Subject: [PATCH 12/70] add some debug output --- .../updater/UpdaterReadCrosslinkConnections.h | 4 ++++ .../UpdaterReadCrosslinkConnectionsTendomer.h | 19 ++++++++-------- projects/TendomerNetworkExtractActivePart.cpp | 22 ++++++++++++++++--- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/include/LeMonADE_PM/updater/UpdaterReadCrosslinkConnections.h b/include/LeMonADE_PM/updater/UpdaterReadCrosslinkConnections.h index 9e2f29c..de40361 100644 --- a/include/LeMonADE_PM/updater/UpdaterReadCrosslinkConnections.h +++ b/include/LeMonADE_PM/updater/UpdaterReadCrosslinkConnections.h @@ -24,6 +24,8 @@ You should have received a copy of the GNU General Public License along with LeMonADE. If not, see . --------------------------------------------------------------------------------*/ +#ifndef LEMONADE_PM_UPDATER_UPDATERREADCROSSLINKCONNECTIONS_H +#define LEMONADE_PM_UPDATER_UPDATERREADCROSSLINKCONNECTIONS_H #include #include #include @@ -208,3 +210,5 @@ bool UpdaterReadCrosslinkConnections::execute(){ return true; } } + +#endif \ No newline at end of file diff --git a/include/LeMonADE_PM/updater/UpdaterReadCrosslinkConnectionsTendomer.h b/include/LeMonADE_PM/updater/UpdaterReadCrosslinkConnectionsTendomer.h index 295dc71..016d43d 100644 --- a/include/LeMonADE_PM/updater/UpdaterReadCrosslinkConnectionsTendomer.h +++ b/include/LeMonADE_PM/updater/UpdaterReadCrosslinkConnectionsTendomer.h @@ -24,6 +24,8 @@ You should have received a copy of the GNU General Public License along with LeMonADE. If not, see . --------------------------------------------------------------------------------*/ +#ifndef LEMONADE_PM_UPDATER_UPDATERREADCROSSLINKCONNECTIONSTENDOMER_H +#define LEMONADE_PM_UPDATER_UPDATERREADCROSSLINKCONNECTIONSTENDOMER_H #include #include #include @@ -145,17 +147,11 @@ template bool UpdaterReadCrosslinkConnectionsTendomer::execute(){ //reset the ingredients container to the inital one ing = initialIng; - //open input file to the connection table - //! stream reading input file + //stream reading input file std::ifstream stream; stream.open(input); if (stream.fail()) throw std::runtime_error(std::string("error opening input file ") + input + std::string("\n")); - bool findStartofData(false); - std::string line; - getline(stream, line); - while (line.empty() || line.at(0) == '#' ) - getline(stream, line); //current conversion auto conversion = minConversion + static_cast(nExecutions) * stepwidth; std::cout << "Current conversion is " <::execute(){ while (NewConnections < ReadNLines && stream.good()){ std::string line; getline(stream, line); - if (line.empty()) - break; + if (line.empty() || line.at(0) == '#' ) + continue; std::stringstream ss; uint32_t Time, createBreak, ChainID, nSegments, MonID1, P1X, P1Y, P1Z, MonID2, P2X, P2Y, P2Z; ss << line; ss >> Time >> createBreak>> ChainID >> nSegments >>MonID1 >> P1X >> P1Y >> P1Z >> MonID2 >> P2X >> P2Y >> P2Z; + #ifdef DEBUG + std::cout << ss.str() << std::endl; + #endif //DEBUG// ing.modifyMolecules().setAge(Time); if ( ConnectCrossLinkToChain(MonID1, ChainID+1) ) { }else if( ConnectCrossLinkToChain(MonID2, ChainID+1) ) { @@ -199,3 +198,5 @@ bool UpdaterReadCrosslinkConnectionsTendomer::execute(){ return true; } } + +#endif \ No newline at end of file diff --git a/projects/TendomerNetworkExtractActivePart.cpp b/projects/TendomerNetworkExtractActivePart.cpp index 0593303..1b4a6ac 100644 --- a/projects/TendomerNetworkExtractActivePart.cpp +++ b/projects/TendomerNetworkExtractActivePart.cpp @@ -112,7 +112,6 @@ int main(int argc, char* argv[]){ taskmanager.cleanup(); std::cout << "Read in conformation and go on to bring it into equilibrium forces..." < activeObject; std::ifstream in(activeComponent); std::string line; @@ -135,7 +134,9 @@ int main(int argc, char* argv[]){ auto tmpAttribute(0); if(objectID < nCrossLinks ){ auto IdX(nChainMonomers+objectID); - // std::cout << "OId=" << objectID << " IdX=" << IdX << std::endl; + #ifdef DEBUG + std::cout << objectID << " " << activeTag << " " << IdX << " " << IdX << std::endl; + #endif if (activeTag == 2 ){ tmpAttribute=1; nActiveCrossLinks++; @@ -144,7 +145,9 @@ int main(int argc, char* argv[]){ }else{ auto IdCStart((objectID-nCrossLinks)*nSegments); auto IdCEnd( (objectID-nCrossLinks+1)*nSegments-1); - // std::cout << "OId=" << objectID << " IdC=" << IdCStart << "-" << IdCEnd << std::endl; + #ifdef DEBUG + std::cout << objectID << " " << activeTag <<" " << IdCStart << " " << IdCEnd << std::endl; + #endif if (activeTag == 2 ) { nActiveTendomers++; tmpAttribute=1; @@ -189,6 +192,19 @@ int main(int argc, char* argv[]){ } myIngredients.synchronize(); + // auto BoxX(myIngredients.getBoxX()); + // auto BoxY(myIngredients.getBoxY()); + // auto BoxZ(myIngredients.getBoxZ()); + // for (auto i=nActiveTendomers*2*myIngredients.getNumMonomersPerChain(); i < myIngredients.getMolecules().size(); i++ ){ + // auto vec(myIngredients.getMolecules()[i].getVector3D()); + // auto new_vec(vec); + // new_vec.setAllCoordinates( LemonadeDistCalcs::fold(vec.getX(),BoxX), + // LemonadeDistCalcs::fold(vec.getX(),BoxY), + // LemonadeDistCalcs::fold(vec.getX(),BoxZ)); + // myIngredients.modifyMolecules()[i].modifyVector3D() = new_vec; + // } + // myIngredients.synchronize(); + TaskManager taskmanager2; taskmanager2.addAnalyzer( new AnalyzerWriteBfmFile(outputBFM, myIngredients, 1) ); //initialize and run From e8bfae616d0d469cd1794b6e267764ab92555817 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Wed, 16 Jun 2021 13:12:00 +0200 Subject: [PATCH 13/70] TendomerNetworkExtractGelPart: extracts the gel part of the networks and write it into a bfm file --- projects/CMakeLists.txt | 2 + projects/TendomerNetworkExtractGelPart.cpp | 237 +++++++++++++++++++++ 2 files changed, 239 insertions(+) create mode 100644 projects/TendomerNetworkExtractGelPart.cpp diff --git a/projects/CMakeLists.txt b/projects/CMakeLists.txt index b7cbc52..9bc852b 100644 --- a/projects/CMakeLists.txt +++ b/projects/CMakeLists.txt @@ -8,6 +8,8 @@ target_link_libraries(TendomerNetworkForceEquilibrium LeMonADE CommandlineParser add_executable(TendomerNetworkExtractActivePart TendomerNetworkExtractActivePart.cpp) target_link_libraries(TendomerNetworkExtractActivePart LeMonADE CommandlineParser ) +add_executable(TendomerNetworkExtractGelPart TendomerNetworkExtractGelPart.cpp) +target_link_libraries(TendomerNetworkExtractGelPart LeMonADE CommandlineParser ) add_executable(TendomerNetworkWritePartialConnectedNetwork TendomerNetworkWritePartialConnectedNetwork.cpp) target_link_libraries(TendomerNetworkWritePartialConnectedNetwork LeMonADE CommandlineParser ) diff --git a/projects/TendomerNetworkExtractGelPart.cpp b/projects/TendomerNetworkExtractGelPart.cpp new file mode 100644 index 0000000..54ce45f --- /dev/null +++ b/projects/TendomerNetworkExtractGelPart.cpp @@ -0,0 +1,237 @@ +/*-------------------------------------------------------------------------------- + ooo L attice-based | + o\.|./o e xtensible | LeMonADE: An Open Source Implementation of the + o\.\|/./o Mon te-Carlo | Bond-Fluctuation-Model for Polymers +oo---0---oo A lgorithm and | + o/./|\.\o D evelopment | Copyright (C) 2013-2015 by + o/.|.\o E nvironment | LeMonADE Principal Developers (see AUTHORS) + ooo | +---------------------------------------------------------------------------------- + +This file is part of LeMonADE. + +LeMonADE 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. + +LeMonADE 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 LeMonADE. If not, see . + +--------------------------------------------------------------------------------*/ + +/****************************************************************************** + * based on LeMonADE: https://github.com/LeMonADE-project/LeMonADE/ + * author: Toni Müller + * email: mueller-toni@ipfdd.de + * project: LeMonADE-Phantom Modulus + *****************************************************************************/ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + + +int main(int argc, char* argv[]){ + try{ + /////////////////////////////////////////////////////////////////////////////// + ///parse options/// + std::string inputBFM("init.bfm"); + std::string outputBFM("Config.bfm.dat"); + std::string inputConnection("BondCreationBreaking.dat"); + std::string activeComponent("active_00001.dat"); + bool showHelp = false; + auto parser + = clara::detail::Opt( inputBFM, "inputBFM (=inconfig.bfm)" ) ["-i"]["--input" ] ("(required)Input filename of the bfm file" ).required() + | clara::detail::Opt( inputConnection, "inputConnection (=BondCreationBreaking.dat)" ) ["-d"]["--inputConnection" ] ("used for the time development of the topology. " ).required() + | clara::detail::Opt( activeComponent, "activeComponents (=active_00001.dat)" ) ["-a"]["--activeComponents"] ("sets the active components . " ).required() + | clara::detail::Opt( outputBFM, "outputBFM (=Config.bfm)" ) ["-o"]["--outputBFM" ] ("Output filename for the active material of the tendomer network.") + | clara::Help( showHelp ); + + auto result = parser.parse( clara::Args( argc, argv ) ); + + if( !result ) { + std::cerr << "Error in command line: " << result.errorMessage() << std::endl; + exit(1); + }else if(showHelp == true){ + std::cout << "Analyzer taking a bond table and a table specifying the activity of an object and writes the active part of the tendoemr network."<< std::endl; + std::cout << "Important: input file for the connections and the active material must fit to each other!!!"<< std::endl; + parser.writeToStream(std::cout); + exit(0); + }else{ + std::cout << "outputBFM : " << outputBFM << std::endl; + std::cout << "inputBFM : " << inputBFM << std::endl; + std::cout << "inputConnection : " << inputConnection << std::endl; + std::cout << "activeComponent : " << activeComponent << std::endl; + } + RandomNumberGenerators rng; + rng.seedAll(); + /////////////////////////////////////////////////////////////////////////////// + ///end options parsing + /////////////////////////////////////////////////////////////////////////////// + //Read in th last Config + typedef LOKI_TYPELIST_4(FeatureMoleculesIOUnsaveCheck, FeatureLabel, FeatureReactiveBonds, FeatureAttributes<>) Features; + typedef ConfigureSystem Config; + typedef Ingredients Ing; + Ing myIngredients; + + TaskManager taskmanager; + + taskmanager.addUpdater( new UpdaterReadBfmFile(inputBFM,myIngredients, UpdaterReadBfmFile::READ_LAST_CONFIG_SAVE),0); + taskmanager.addUpdater( new UpdaterReadCrosslinkConnectionsTendomer(myIngredients, inputConnection, 0., 1.0) ); + + //initialize and run + taskmanager.initialize(); + taskmanager.run(1); + taskmanager.cleanup(); + std::cout << "Read in conformation and go on to bring it into equilibrium forces..." <>activeTag; + auto tmpAttribute(0); + if(objectID < nCrossLinks ){ + auto IdX(nChainMonomers+objectID); + #ifdef DEBUG + std::cout << objectID << " " << activeTag << " " << IdX << " " << IdX << std::endl; + #endif + if (activeTag == 2 || activeTag == 1 ){ + tmpAttribute=1; + nActiveCrossLinks++; + } + myIngredients.modifyMolecules()[nChainMonomers+objectID].setAttributeTag(tmpAttribute); + }else{ + auto IdCStart((objectID-nCrossLinks)*nSegments); + auto IdCEnd( (objectID-nCrossLinks+1)*nSegments-1); + #ifdef DEBUG + std::cout << objectID << " " << activeTag <<" " << IdCStart << " " << IdCEnd << std::endl; + #endif + if (activeTag == 2 || activeTag == 1 ) { + nActiveTendomers++; + tmpAttribute=1; + } + for (auto i =IdCStart ; i <= IdCEnd; i++ ) + myIngredients.modifyMolecules()[i].setAttributeTag(tmpAttribute); + } + objectID++; + } + } + std::cout <<"Fileend:\n" ; + // for() + myIngredients.setNumTendomers (nActiveTendomers); + myIngredients.setNumCrossLinkers (nActiveCrossLinks); + myIngredients.setNumMonomersPerChain (myIngredients.getNumMonomersPerChain()); + myIngredients.setNumLabelsPerTendomerArm(myIngredients.getNumLabelsPerTendomerArm()); + myIngredients.synchronize(); + + + MonomerGroup subgroup(myIngredients.getMolecules()); + subgroup.clear(); + hasThisType<1> predicate; + for(size_t n=0;n(outputBFM, myIngredients, 1) ); + //initialize and run + if ( nActiveTendomers > 0 ){ + taskmanager2.initialize(); + taskmanager2.run(1); + taskmanager2.cleanup(); + } + // AnalyzerWriteBfmFileSubGroup > writer(outputBFM, myIngredients, 1, hasThisType<1>()); + // writer.initialize(); + + // TaskManager taskmanager2; + // taskmanager2.addAnalyzer( new AnalyzerWriteBfmFileSubGroup >(outputBFM, myIngredients, 1, hasThisType<1>()) ); + + // //initialize and run + // taskmanager2.initialize(); + // taskmanager2.run(1); + // // taskmanager2.cleanup(); + + } + catch(std::exception& e){ + std::cerr<<"Error:\n" + < Date: Wed, 16 Jun 2021 13:13:51 +0200 Subject: [PATCH 14/70] us the TM updater for the FE-eq in the standard ForceEquilibrium.cpp --- projects/ForceEquilibrium.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/ForceEquilibrium.cpp b/projects/ForceEquilibrium.cpp index a7142b0..9ab6605 100644 --- a/projects/ForceEquilibrium.cpp +++ b/projects/ForceEquilibrium.cpp @@ -160,7 +160,8 @@ int main(int argc, char* argv[]){ //read bonds and positions stepwise taskmanager2.addUpdater( new UpdaterReadCrosslinkConnections(myIngredients2, inputConnection, stepwidth, minConversion) ); // if (custom) - taskmanager2.addUpdater( new UpdaterForceBalancedPosition(myIngredients2, threshold) ); + // taskmanager2.addUpdater( new UpdaterForceBalancedPosition(myIngredients2, threshold) ); + taskmanager2.addUpdater( new UpdaterForceBalancedPositionTendomer(myIngredients2, threshold) ); // else { // auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; // updater->setFilename(feCurve); From 68125262955b906e532146e000e2b58af56707e0 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Wed, 16 Jun 2021 13:27:27 +0200 Subject: [PATCH 15/70] add the settre and getter for the filename and the relaxation factor to the base class --- .../updater/moves/MoveForceEquilibriumBase.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/LeMonADE_PM/updater/moves/MoveForceEquilibriumBase.h b/include/LeMonADE_PM/updater/moves/MoveForceEquilibriumBase.h index fe42bcc..a8e4979 100644 --- a/include/LeMonADE_PM/updater/moves/MoveForceEquilibriumBase.h +++ b/include/LeMonADE_PM/updater/moves/MoveForceEquilibriumBase.h @@ -88,6 +88,16 @@ class MoveForceEquilibriumBase:public MoveBase { ShiftVector.setAllCoordinates(dx,dy,dz); } + + void setFilename(std::string filename_){static_cast(this)->setFilename(ingredients);} + //! get the filename for the force extension data + std::string const getFilename(){static_cast(this)->getFilename(ingredients);} + + //! set the relaxation parameter for the cross link + void setRelaxationParameter(double relaxationChain_){static_cast(this)->setRelaxationParameter(ingredients);} + //! get the relaxation parameter for the cross link + double getRelaxationParameter(){static_cast(this)->getRelaxationParameter(ingredients);} + //! Random Number Generator (RNG) RandomNumberGenerators randomNumbers; From 42d2fcb5c059aa060d911514a85cc161403f1620 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Wed, 16 Jun 2021 13:27:27 +0200 Subject: [PATCH 16/70] add the settre and getter for the filename and the relaxation factor to the base class --- .../updater/moves/MoveForceEquilibriumBase.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/LeMonADE_PM/updater/moves/MoveForceEquilibriumBase.h b/include/LeMonADE_PM/updater/moves/MoveForceEquilibriumBase.h index fe42bcc..a31d379 100644 --- a/include/LeMonADE_PM/updater/moves/MoveForceEquilibriumBase.h +++ b/include/LeMonADE_PM/updater/moves/MoveForceEquilibriumBase.h @@ -88,6 +88,16 @@ class MoveForceEquilibriumBase:public MoveBase { ShiftVector.setAllCoordinates(dx,dy,dz); } + + void setFilename(std::string filename_){static_cast(this)->setFilename(filename_);} + //! get the filename for the force extension data + std::string const getFilename(){static_cast(this)->getFilename();} + + //! set the relaxation parameter for the cross link + void setRelaxationParameter(double relaxationChain_){static_cast(this)->setRelaxationParameter(relaxationChain_);} + //! get the relaxation parameter for the cross link + double getRelaxationParameter(){static_cast(this)->getRelaxationParameter();} + //! Random Number Generator (RNG) RandomNumberGenerators randomNumbers; From 6377e9a4013905e909e6bbc47ce82a04fa6c529c Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Wed, 16 Jun 2021 13:40:01 +0200 Subject: [PATCH 17/70] Erase the Tendomer specific updater for the force balance and instead generalize the base move a bit. --- .../updater/UpdaterForceBalancedPosition.h | 22 +++- .../UpdaterForceBalancedPositionTendomer.h | 111 ------------------ .../updater/moves/MoveForceEquilibriumBase.h | 2 +- projects/ForceEquilibrium.cpp | 37 +++--- projects/TendomerNetworkExtractActivePart.cpp | 1 - projects/TendomerNetworkExtractGelPart.cpp | 1 - projects/TendomerNetworkForceEquilibrium.cpp | 4 +- ...merNetworkWritePartialConnectedNetwork.cpp | 2 +- 8 files changed, 42 insertions(+), 138 deletions(-) delete mode 100644 include/LeMonADE_PM/updater/UpdaterForceBalancedPositionTendomer.h diff --git a/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h b/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h index 34e97bf..0a04210 100644 --- a/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h +++ b/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h @@ -40,12 +40,15 @@ class UpdaterForceBalancedPosition:public AbstractUpdater { public: //! constructor for UpdaterForceBalancedPosition - UpdaterForceBalancedPosition(IngredientsType& ing_, double threshold_ ): - ing(ing_),threshold(threshold_){}; + UpdaterForceBalancedPosition(IngredientsType& ing_, double threshold_, double factor_=0.995 ): + ing(ing_),threshold(threshold_),factor(factor_){}; - virtual void initialize(){} + virtual void initialize(){relaxationParameter=move.getRelaxationParameter();}// init(move);}; bool execute(); virtual void cleanup(){}; + + void setFilename(const std::string filename) {move.setFilename(filename); } + void setRelaxationParameter( const double relax ) {move.setRelaxationParameter(relax);} private: //!copy of the main container for the system informations IngredientsType& ing; @@ -53,6 +56,10 @@ class UpdaterForceBalancedPosition:public AbstractUpdater //! threshold for the certainty double threshold; + double relaxationParameter; + + double factor; + //! move to equilibrate the cross links by force equilibrium moveType move; @@ -63,8 +70,10 @@ class UpdaterForceBalancedPosition:public AbstractUpdater template bool UpdaterForceBalancedPosition::execute(){ std::cout << "UpdaterForceBalancedPosition::execute(): Start equilibration" <::execute(){ } if( NSuccessfulMoves>0 ){ avShift/=(NSuccessfulMoves); - }else + counter=0; + }else { avShift=threshold*1.1; + counter++; + } + if (counter > 10 ){break;} ing.modifyMolecules().setAge(ing.getMolecules().getAge()+1); if (ing.getMolecules().getAge() %1000 == 0 ){ std::cout << "MCS: " << ing.getMolecules().getAge() << " and average shift: " << avShift << std::endl; + setRelaxationParameter(move.getRelaxationParameter()*factor ); } } std::cout << "Finish equilibration with average shift per cross link < " << avShift << " after " << ing.getMolecules().getAge()-StartMCS <. - ---------------------------------------------------------------------------------*/ -#ifndef LEMONADE_PM_UPDATER_UPDATERFORCEBALANCEPOSITIONTENDOMER_H -#define LEMONADE_PM_UPDATER_UPDATERFORCEBALANCEPOSITIONTENDOMER_H - - -#include -#include - /** - * @class UpdaterForceBalancedPositionTendomer - * @tparam IngredientsType - */ - - template -class UpdaterForceBalancedPositionTendomer:public AbstractUpdater -{ -public: - //! constructor for UpdaterForceBalancedPositionTendomer - UpdaterForceBalancedPositionTendomer(IngredientsType& ing_, double threshold_, double factor_=0.995 ): - ing(ing_),threshold(threshold_),factor(factor_){}; - - virtual void initialize(){relaxationParameter=move.getRelaxationParameter();}// init(move);}; - bool execute(); - virtual void cleanup(){}; - - void setFilename(const std::string filename) {move.setFilename(filename); } - void setRelaxationParameter( const double relax ) {move.setRelaxationParameter(relax);} -private: - //!copy of the main container for the system informations - IngredientsType& ing; - - //! threshold for the certainty - double threshold; - - double relaxationParameter; - - double factor; - - //! move to equilibrate the cross links by force equilibrium - moveType move; - - //! random number generator - RandomNumberGenerators rng; - -}; -template -bool UpdaterForceBalancedPositionTendomer::execute(){ - std::cout << "UpdaterForceBalancedPositionTendomer::execute(): Start equilibration" < threshold ){ - double NSuccessfulMoves(0.); - avShift=0.0; - for (uint32_t i =0 ; i0 ){ - avShift/=(NSuccessfulMoves); - counter=0; - }else { - avShift=threshold*1.1; - counter++; - } - if (counter > 10 ){break;} - ing.modifyMolecules().setAge(ing.getMolecules().getAge()+1); - if (ing.getMolecules().getAge() %1000 == 0 ){ - std::cout << "MCS: " << ing.getMolecules().getAge() << " and average shift: " << avShift << std::endl; - setRelaxationParameter(move.getRelaxationParameter()*factor ); - } - } - std::cout << "Finish equilibration with average shift per cross link < " << avShift << " after " << ing.getMolecules().getAge()-StartMCS <(this)->setFilename(filename_);} //! get the filename for the force extension data std::string const getFilename(){static_cast(this)->getFilename();} diff --git a/projects/ForceEquilibrium.cpp b/projects/ForceEquilibrium.cpp index 9ab6605..b7db1b5 100644 --- a/projects/ForceEquilibrium.cpp +++ b/projects/ForceEquilibrium.cpp @@ -62,12 +62,12 @@ int main(int argc, char* argv[]){ std::string outputDataPos("CrosslinkPosition.dat"); std::string outputDataDist("ChainExtensionDistribution.dat"); std::string inputConnection("BondCreationBreaking.dat"); - // std::string feCurve(""); - // double relaxationParameter(10.); + std::string feCurve(""); + double relaxationParameter(10.); double threshold(0.5); double stepwidth(1.0); double minConversion(50.0); - // bool custom(true); + bool custom(true); bool showHelp = false; auto parser @@ -78,8 +78,8 @@ int main(int argc, char* argv[]){ | clara::detail::Opt( stepwidth, "stepwidth" ) ["-s"]["--stepwidth" ] ("(optional) Width for the increase in percentage. Default: 1%." ).optional() | clara::detail::Opt( minConversion, "minConversion" ) ["-u"]["--minConversion" ] ("(optional) Minimum conversion to be read in. Default: 50%." ).optional() | clara::detail::Opt( threshold, "threshold" ) ["-t"]["--threshold" ] ("(optional) Threshold of the average shift. Default 0.5 ." ).optional() - // | clara::detail::Opt( feCurve, "feCurve (="")" ) ["-f"]["--feCurve" ] ("(optional) Force-Extension curve. Default \"\"." ).optional() - // | clara::detail::Opt( relaxationParameter, "relaxationParameter (=10)" ) ["-r"]["--relax" ] ("(optional) Relaxation parameter. Default 10.0 ." ).optional() + | clara::detail::Opt( feCurve, "feCurve (="")" ) ["-f"]["--feCurve" ] ("(optional) Force-Extension curve. Default \"\"." ).optional() + | clara::detail::Opt( relaxationParameter, "relaxationParameter (=10)" ) ["-r"]["--relax" ] ("(optional) Relaxation parameter. Default 10.0 ." ).optional() | clara::Help( showHelp ); auto result = parser.parse( clara::Args( argc, argv ) ); @@ -99,9 +99,9 @@ int main(int argc, char* argv[]){ std::cout << "stepwidth : " << stepwidth << std::endl; std::cout << "minConversion : " << minConversion << std::endl; std::cout << "threshold : " << threshold << std::endl; - // std::cout << "feCurve : " << feCurve << std::endl; + std::cout << "feCurve : " << feCurve << std::endl; } - // if (! feCurve.empty()) custom=false; + if (! feCurve.empty()) custom=false; RandomNumberGenerators rng; @@ -155,19 +155,22 @@ int main(int argc, char* argv[]){ } } myIngredients2.synchronize(); - + + TaskManager taskmanager2; //read bonds and positions stepwise taskmanager2.addUpdater( new UpdaterReadCrosslinkConnections(myIngredients2, inputConnection, stepwidth, minConversion) ); - // if (custom) - // taskmanager2.addUpdater( new UpdaterForceBalancedPosition(myIngredients2, threshold) ); - taskmanager2.addUpdater( new UpdaterForceBalancedPositionTendomer(myIngredients2, threshold) ); - // else { - // auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; - // updater->setFilename(feCurve); - // updater->setRelaxationParameter(relaxationParameter); - // taskmanager2.addUpdater( updater ); - // } + if(custom){ + auto forceUpdater = new UpdaterForceBalancedPosition(myIngredients2, threshold); + forceUpdater->setFilename(feCurve); + forceUpdater->setRelaxationParameter(relaxationParameter); + taskmanager2.addUpdater( forceUpdater ); + } else { + auto forceUpdater = new UpdaterForceBalancedPosition(myIngredients2, threshold); + forceUpdater->setFilename(feCurve); + forceUpdater->setRelaxationParameter(relaxationParameter); + taskmanager2.addUpdater( forceUpdater ); + } taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,outputDataPos, outputDataDist)); //initialize and run taskmanager2.initialize(); diff --git a/projects/TendomerNetworkExtractActivePart.cpp b/projects/TendomerNetworkExtractActivePart.cpp index 1b4a6ac..6b3b45d 100644 --- a/projects/TendomerNetworkExtractActivePart.cpp +++ b/projects/TendomerNetworkExtractActivePart.cpp @@ -50,7 +50,6 @@ along with LeMonADE. If not, see . #include -#include #include #include #include diff --git a/projects/TendomerNetworkExtractGelPart.cpp b/projects/TendomerNetworkExtractGelPart.cpp index 54ce45f..d427664 100644 --- a/projects/TendomerNetworkExtractGelPart.cpp +++ b/projects/TendomerNetworkExtractGelPart.cpp @@ -50,7 +50,6 @@ along with LeMonADE. If not, see . #include -#include #include #include #include diff --git a/projects/TendomerNetworkForceEquilibrium.cpp b/projects/TendomerNetworkForceEquilibrium.cpp index 764df5d..cffe0b5 100644 --- a/projects/TendomerNetworkForceEquilibrium.cpp +++ b/projects/TendomerNetworkForceEquilibrium.cpp @@ -47,7 +47,7 @@ along with LeMonADE. If not, see . #include -#include +#include #include #include #include @@ -149,7 +149,7 @@ int main(int argc, char* argv[]){ TaskManager taskmanager2; //read bonds and positions stepwise - auto updater = new UpdaterForceBalancedPositionTendomer(myIngredients2, threshold, factor) ; + auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold, factor) ; updater->setFilename(feCurve); updater->setRelaxationParameter(relaxationParameter); // auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; diff --git a/projects/TendomerNetworkWritePartialConnectedNetwork.cpp b/projects/TendomerNetworkWritePartialConnectedNetwork.cpp index bcbc61b..5f56641 100644 --- a/projects/TendomerNetworkWritePartialConnectedNetwork.cpp +++ b/projects/TendomerNetworkWritePartialConnectedNetwork.cpp @@ -50,7 +50,7 @@ along with LeMonADE. If not, see . #include -#include + #include #include #include From 1ed297188c3f4f8f6ad9166a8703c5213d34b5c7 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Wed, 16 Jun 2021 14:17:36 +0200 Subject: [PATCH 18/70] remove updater for testint purposes --- .../updater/UpdaterForceBalancedPosition.h | 27 ++++++++++--------- projects/ForceEquilibrium.cpp | 10 +++---- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h b/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h index 0a04210..cb89d2b 100644 --- a/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h +++ b/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h @@ -41,7 +41,7 @@ class UpdaterForceBalancedPosition:public AbstractUpdater public: //! constructor for UpdaterForceBalancedPosition UpdaterForceBalancedPosition(IngredientsType& ing_, double threshold_, double factor_=0.995 ): - ing(ing_),threshold(threshold_),factor(factor_){}; + ing(ing_),threshold(threshold_),factor(factor_),relaxationParameter(1.0){}; virtual void initialize(){relaxationParameter=move.getRelaxationParameter();}// init(move);}; bool execute(); @@ -70,10 +70,10 @@ class UpdaterForceBalancedPosition:public AbstractUpdater template bool UpdaterForceBalancedPosition::execute(){ std::cout << "UpdaterForceBalancedPosition::execute(): Start equilibration" <::execute(){ NSuccessfulMoves++; } } - if( NSuccessfulMoves>0 ){ - avShift/=(NSuccessfulMoves); - counter=0; - }else { - avShift=threshold*1.1; - counter++; - } - if (counter > 10 ){break;} - ing.modifyMolecules().setAge(ing.getMolecules().getAge()+1); + // if( NSuccessfulMoves == 0 ){ return false;} + // if( NSuccessfulMoves>0 ){ + // avShift/=(NSuccessfulMoves); + // counter=0; + // }else { + // avShift=threshold*1.1; + // counter++; + // } + // if (counter > 10 ){break;} + ing.modifyMolecules().setAge(ing.getMolecules().getAge()+1); if (ing.getMolecules().getAge() %1000 == 0 ){ std::cout << "MCS: " << ing.getMolecules().getAge() << " and average shift: " << avShift << std::endl; - setRelaxationParameter(move.getRelaxationParameter()*factor ); + // setRelaxationParameter(move.getRelaxationParameter()*factor ); } } std::cout << "Finish equilibration with average shift per cross link < " << avShift << " after " << ing.getMolecules().getAge()-StartMCS <(myIngredients2, inputConnection, stepwidth, minConversion) ); if(custom){ + std::cout << "Use custom force-extension curve\n"; auto forceUpdater = new UpdaterForceBalancedPosition(myIngredients2, threshold); forceUpdater->setFilename(feCurve); forceUpdater->setRelaxationParameter(relaxationParameter); taskmanager2.addUpdater( forceUpdater ); } else { + std::cout << "Use gaussian force-extension relation\n"; auto forceUpdater = new UpdaterForceBalancedPosition(myIngredients2, threshold); - forceUpdater->setFilename(feCurve); - forceUpdater->setRelaxationParameter(relaxationParameter); - taskmanager2.addUpdater( forceUpdater ); + // taskmanager2.addUpdater( forceUpdater ); } taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,outputDataPos, outputDataDist)); //initialize and run From 3c826aa4c30081e999d874eb6e95dfb7e7c9313c Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Wed, 16 Jun 2021 14:41:20 +0200 Subject: [PATCH 19/70] resubmit the upter --- projects/ForceEquilibrium.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/ForceEquilibrium.cpp b/projects/ForceEquilibrium.cpp index a309cb6..7460b03 100644 --- a/projects/ForceEquilibrium.cpp +++ b/projects/ForceEquilibrium.cpp @@ -169,12 +169,12 @@ int main(int argc, char* argv[]){ } else { std::cout << "Use gaussian force-extension relation\n"; auto forceUpdater = new UpdaterForceBalancedPosition(myIngredients2, threshold); - // taskmanager2.addUpdater( forceUpdater ); + taskmanager2.addUpdater( forceUpdater ); } taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,outputDataPos, outputDataDist)); //initialize and run taskmanager2.initialize(); - taskmanager2.run(); + taskmanager2.run(1); taskmanager2.cleanup(); } From fa97f22c37498c69d639eadcb262ef891e86c75c Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Wed, 16 Jun 2021 14:53:08 +0200 Subject: [PATCH 20/70] fix bug: add aempty function to specialized moves --- .../updater/moves/MoveForceEquilibrium.h | 12 ++++++++- projects/ForceEquilibrium.cpp | 26 ++++++++++++------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/include/LeMonADE_PM/updater/moves/MoveForceEquilibrium.h b/include/LeMonADE_PM/updater/moves/MoveForceEquilibrium.h index 4909893..f1d7a17 100644 --- a/include/LeMonADE_PM/updater/moves/MoveForceEquilibrium.h +++ b/include/LeMonADE_PM/updater/moves/MoveForceEquilibrium.h @@ -47,7 +47,9 @@ along with LeMonADE. If not, see . class MoveForceEquilibrium:public MoveForceEquilibriumBase{ public: - MoveForceEquilibrium():bondlength(2.68){}; + MoveForceEquilibrium():bondlength(2.68){ + std::cout << "Use the MoveForceEquilibrium\n"; + }; // overload initialise function to be able to set the moves index and direction if neccessary template void init(const IngredientsType& ing); @@ -57,6 +59,14 @@ class MoveForceEquilibrium:public MoveForceEquilibriumBase template bool check(IngredientsType& ing); template< class IngredientsType> void apply(IngredientsType& ing); + void setFilename(std::string filename_){} + //! get the filename for the force extension data + std::string const getFilename(){} + + //! set the relaxation parameter for the cross link + void setRelaxationParameter(double relaxationChain_){} + //! get the relaxation parameter for the cross link + double getRelaxationParameter(){} private: //average square bond length const double bondlength; diff --git a/projects/ForceEquilibrium.cpp b/projects/ForceEquilibrium.cpp index 7460b03..9325f4a 100644 --- a/projects/ForceEquilibrium.cpp +++ b/projects/ForceEquilibrium.cpp @@ -157,26 +157,34 @@ int main(int argc, char* argv[]){ myIngredients2.synchronize(); - TaskManager taskmanager2; - //read bonds and positions stepwise - taskmanager2.addUpdater( new UpdaterReadCrosslinkConnections(myIngredients2, inputConnection, stepwidth, minConversion) ); + if(custom){ + TaskManager taskmanager2; + //read bonds and positions stepwise + taskmanager2.addUpdater( new UpdaterReadCrosslinkConnections(myIngredients2, inputConnection, stepwidth, minConversion) ); std::cout << "Use custom force-extension curve\n"; auto forceUpdater = new UpdaterForceBalancedPosition(myIngredients2, threshold); forceUpdater->setFilename(feCurve); forceUpdater->setRelaxationParameter(relaxationParameter); taskmanager2.addUpdater( forceUpdater ); + taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,outputDataPos, outputDataDist)); + //initialize and run + taskmanager2.initialize(); + taskmanager2.run(1); + taskmanager2.cleanup(); } else { + TaskManager taskmanager2; + //read bonds and positions stepwise + taskmanager2.addUpdater( new UpdaterReadCrosslinkConnections(myIngredients2, inputConnection, stepwidth, minConversion) ); std::cout << "Use gaussian force-extension relation\n"; auto forceUpdater = new UpdaterForceBalancedPosition(myIngredients2, threshold); taskmanager2.addUpdater( forceUpdater ); + taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,outputDataPos, outputDataDist)); + //initialize and run + taskmanager2.initialize(); + taskmanager2.run(1); + taskmanager2.cleanup(); } - taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,outputDataPos, outputDataDist)); - //initialize and run - taskmanager2.initialize(); - taskmanager2.run(1); - taskmanager2.cleanup(); - } catch(std::exception& e){ std::cerr<<"Error:\n" From 4b08a2fc6d7c90c24bf4da5e9978e7758d5104f2 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Thu, 17 Jun 2021 17:28:02 +0200 Subject: [PATCH 21/70] add a finer splitting of the extensions for the custom FE curve vector --- .../moves/MoveNonLinearForceEquilibrium.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/include/LeMonADE_PM/updater/moves/MoveNonLinearForceEquilibrium.h b/include/LeMonADE_PM/updater/moves/MoveNonLinearForceEquilibrium.h index 5af3ff1..2624a35 100644 --- a/include/LeMonADE_PM/updater/moves/MoveNonLinearForceEquilibrium.h +++ b/include/LeMonADE_PM/updater/moves/MoveNonLinearForceEquilibrium.h @@ -51,7 +51,7 @@ class MoveNonLinearForceEquilibrium:public MoveForceEquilibriumBase(round(extensionVector.getLength())) ); - if ( max_extension < length ){ + uint32_t length( static_cast(round(extensionVector.getLength()/accuracy)) ); + if ( max_extension/accuracy < length ){ std::stringstream errormessage; errormessage << "The length of the extension vector is greater than the maximum given in the file: \n" - << "length is " << length + << "length is " << length*accuracy << " maximum is " << max_extension << "\n"; throw std::runtime_error(errormessage.str()); } @@ -122,6 +123,9 @@ class MoveNonLinearForceEquilibrium:public MoveForceEquilibriumBase(max_extension); r++ ){ + for ( auto r=0;r(max_extension/accuracy); r++ ){ if(r==0) force_extension.push_back(0.); else{ auto it_last=extension_force.begin(); for (auto it=extension_force.begin(); it !=extension_force.end();it++){ - if(it->second > r){ + if(it->second > static_cast(r*accuracy)){ //at the force linear interpolated in between the two current forces auto deltaForce(it->first-it_last->first); auto deltaExtension(it->second-it_last->second); From 0fd08f0eccb306f1f65d650cb5beb53a3fc8cbc7 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Mon, 21 Jun 2021 08:30:02 +0200 Subject: [PATCH 22/70] correct output format for the ids in the analyzer --- .../LeMonADE_PM/analyzer/AnalyzerEquilbratedPosition.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/LeMonADE_PM/analyzer/AnalyzerEquilbratedPosition.h b/include/LeMonADE_PM/analyzer/AnalyzerEquilbratedPosition.h index eb5961d..bb32639 100644 --- a/include/LeMonADE_PM/analyzer/AnalyzerEquilbratedPosition.h +++ b/include/LeMonADE_PM/analyzer/AnalyzerEquilbratedPosition.h @@ -75,7 +75,7 @@ template < class IngredientsType > class AnalyzerEquilbratedPosition : public Ab std::vector< std::vector > CalculateDistance(); //! just collects the id and the position for the cross links - std::vector > CollectAveragePositions(); + std::vector > CollectAveragePositions(); }; /************************************************************************* @@ -128,8 +128,8 @@ std::vector< std::vector > AnalyzerEquilbratedPosition } //////////////////////////////////////////////////////////////////////////////// template< class IngredientsType > -std::vector< std::vector > AnalyzerEquilbratedPosition::CollectAveragePositions(){ - std::vector > AveragePosition(4, std::vector()); +std::vector< std::vector > AnalyzerEquilbratedPosition::CollectAveragePositions(){ + std::vector > AveragePosition(4, std::vector()); auto crosslinkID(ingredients.getCrosslinkIDs()); for (size_t i = 0 ; i < crosslinkID.size(); i++){ auto IDx(crosslinkID[i]); @@ -189,7 +189,7 @@ void AnalyzerEquilbratedPosition::dumpData() std::cout << "////////////////////////////////////"< > CrossLinkPositions=CollectAveragePositions() ; + std::vector< std::vector > CrossLinkPositions=CollectAveragePositions() ; std::stringstream commentAveragePosition; commentAveragePosition<<"Created by AnalyzerEquilbratedPosition\n"; commentAveragePosition<<"ID's start at 0 \n"; From ea6430a78395bda52ddf8735b56d89b84a5f6900 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Mon, 21 Jun 2021 08:31:23 +0200 Subject: [PATCH 23/70] mroe efficient calcualtion and output for finding deviations from the expected behaviour --- .../updater/moves/MoveForceEquilibrium.h | 9 ++- .../moves/MoveNonLinearForceEquilibrium.h | 76 ++++++++++++++----- 2 files changed, 63 insertions(+), 22 deletions(-) diff --git a/include/LeMonADE_PM/updater/moves/MoveForceEquilibrium.h b/include/LeMonADE_PM/updater/moves/MoveForceEquilibrium.h index f1d7a17..d3e669b 100644 --- a/include/LeMonADE_PM/updater/moves/MoveForceEquilibrium.h +++ b/include/LeMonADE_PM/updater/moves/MoveForceEquilibrium.h @@ -47,7 +47,7 @@ along with LeMonADE. If not, see . class MoveForceEquilibrium:public MoveForceEquilibriumBase{ public: - MoveForceEquilibrium():bondlength(2.68){ + MoveForceEquilibrium():bondlength2(2.68*2.68){ std::cout << "Use the MoveForceEquilibrium\n"; }; @@ -69,17 +69,18 @@ class MoveForceEquilibrium:public MoveForceEquilibriumBase double getRelaxationParameter(){} private: //average square bond length - const double bondlength; + const double bondlength2; + // //Gaussina force extension relation //f=R*3/(N*b^2) VectorDouble3 FE(VectorDouble3 extensionVector, double nSegs){ - return extensionVector*3./((nSegs)*bondlength*bondlength); + return extensionVector*3./((nSegs)*bondlength2); } //Gaussian extension force relation //R=-f/3*N*b^2 VectorDouble3 EF(VectorDouble3 force, double nSegs){ - return force/(3.)*(nSegs)*bondlength*bondlength; + return force/(3.)*(nSegs)*bondlength2; } //calculate the shift for the cross link diff --git a/include/LeMonADE_PM/updater/moves/MoveNonLinearForceEquilibrium.h b/include/LeMonADE_PM/updater/moves/MoveNonLinearForceEquilibrium.h index 2624a35..dd1b04a 100644 --- a/include/LeMonADE_PM/updater/moves/MoveNonLinearForceEquilibrium.h +++ b/include/LeMonADE_PM/updater/moves/MoveNonLinearForceEquilibrium.h @@ -51,7 +51,7 @@ class MoveNonLinearForceEquilibrium:public MoveForceEquilibriumBase(round(extensionVector.getLength()/accuracy)) ); - if ( max_extension/accuracy < length ){ + if (extensionVector == VectorDouble3(0.,0.,0.) ) + return VectorDouble3(0.,0.,0.); + double length( extensionVector.getLength() ); + + #ifdef DEBUG + if ( max_extension < length ){ std::stringstream errormessage; errormessage << "The length of the extension vector is greater than the maximum given in the file: \n" - << "length is " << length*accuracy + << "length is " << length << " maximum is " << max_extension << "\n"; throw std::runtime_error(errormessage.str()); } if (length == 0 ) return VectorDouble3(0.,0.,0.); - return force_extension[length]*extensionVector.normalize(); + #endif + #ifdef DEBUG + std::cout <(round(length/accuracy))] << "\t" << EFGauss(extensionVector).getLength() << "\t" + << extensionVector << "\t" + << EFGauss(extensionVector) << "\t"<< extensionVector.normalize()*(force_extension[static_cast(round(length/accuracy))])<<"\t" + << "\n"; + #endif + if (length < 1 ) + return EFGauss(extensionVector); + // if (length < 0.001 ) + // return VectorDouble3(0.,0.,0.); + return extensionVector.normalize()*(force_extension[static_cast(round(length/accuracy))]); } + //Gaussina force extension relation + //f=R*3/(N*b^2) + VectorDouble3 EFGauss(VectorDouble3 extensionVector){ + return extensionVector/springConstant; + } //Gaussian extension force relation //R=-f/3*N*b^2 VectorDouble3 FE(VectorDouble3 const force ) const { @@ -124,7 +145,7 @@ class MoveNonLinearForceEquilibrium:public MoveForceEquilibriumBase Neighbors(ing.getCrossLinkNeighborIDs(this->getIndex()) ); VectorDouble3 force(0.,0.,0.); + // VectorDouble3 force2(0.,0.,0.); VectorDouble3 shift(0.,0.,0.); + // VectorDouble3 shift2(0.,0.,0.); double avNSegments(0.); - if (Neighbors.size() > 0) { + int32_t number_of_neighbors(Neighbors.size()); + if (number_of_neighbors > 0) { VectorDouble3 Position(ing.getMolecules()[this->getIndex()].getVector3D()); - for (size_t i = 0; i < Neighbors.size(); i++){ - VectorDouble3 vec(Position-ing.getMolecules()[Neighbors[i].ID].getVector3D()+Neighbors[i].jump); - // std::cout << Position << " " << ing.getMolecules()[Neighbors[i].ID].getVector3D() << " " << Neighbors[i].jump <<"\n"; - force+=EF(vec);//Neighbors[i].segDistance + for (size_t i = 0; i < number_of_neighbors; i++){ + VectorDouble3 vec(ing.getMolecules()[Neighbors[i].ID].getVector3D()-Neighbors[i].jump-Position); + force+=EF(vec); + // force2+=EFGauss(vec); + if (ing.getMolecules().getAge()%1000 == 999 && ing.getMolecules().getAge()>49000) + std::cout << vec.getLength() << " " << ing.getMolecules()[Neighbors[i].ID].getVector3D()<< " " << Neighbors[i].jump<< " " << Position <<" " ; } - shift=FE(force/(static_cast(Neighbors.size()) )); + shift=FE(force/(static_cast(number_of_neighbors) )); + // shift2=FE(force2/(static_cast(number_of_neighbors) )); + if (ing.getMolecules().getAge()%1000 == 999 && ing.getMolecules().getAge()>49000) + // if(shift.getLength() > .001 ){ + std::cout << "i="<getIndex() <<" " + << shift <<" " <(max_extension/accuracy); r++ ){ if(r==0) force_extension.push_back(0.); else{ - auto it_last=extension_force.begin(); - for (auto it=extension_force.begin(); it !=extension_force.end();it++){ + for (auto it=it_last; it !=extension_force.end();it++){ if(it->second > static_cast(r*accuracy)){ //at the force linear interpolated in between the two current forces auto deltaForce(it->first-it_last->first); auto deltaExtension(it->second-it_last->second); - auto factor( (static_cast(r)-it_last->second)/deltaExtension ); + auto factor( (static_cast(r*accuracy)-it_last->second)/deltaExtension ); //at interpolated force force_extension.push_back(it_last->first+deltaForce*factor); break; @@ -213,8 +253,8 @@ void MoveNonLinearForceEquilibrium::createTable(){ } } std::cout << "MoveNonLinearForceEquilibrium::createTable() force extension" < Date: Mon, 21 Jun 2021 11:38:48 +0200 Subject: [PATCH 24/70] use linear interpolation in force extension curve for calculating the force within the steps --- .../moves/MoveNonLinearForceEquilibrium.h | 42 +++++++++++++------ 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/include/LeMonADE_PM/updater/moves/MoveNonLinearForceEquilibrium.h b/include/LeMonADE_PM/updater/moves/MoveNonLinearForceEquilibrium.h index dd1b04a..7c333a5 100644 --- a/include/LeMonADE_PM/updater/moves/MoveNonLinearForceEquilibrium.h +++ b/include/LeMonADE_PM/updater/moves/MoveNonLinearForceEquilibrium.h @@ -51,7 +51,7 @@ class MoveNonLinearForceEquilibrium:public MoveForceEquilibriumBase(round(length/accuracy))])<<"\t" << "\n"; #endif - if (length < 1 ) - return EFGauss(extensionVector); + // if (length < 1 ) + // return EFGauss(extensionVector); // if (length < 0.001 ) // return VectorDouble3(0.,0.,0.); - return extensionVector.normalize()*(force_extension[static_cast(round(length/accuracy))]); + if (length == 0) + return VectorDouble3(0.,0.,0.); + auto x(length/accuracy); + auto up (static_cast(floor((length)/accuracy)+1)); + auto down(static_cast(floor(length/accuracy))); + auto amplitude=force_extension[down] + (force_extension[up]-force_extension[down])/static_cast(up-down)*(x-down)/static_cast(up-down); + // std::cout<< "amp=" << amplitude<< std::endl; + // extensionVector.normalize(); + return extensionVector.normalize()*(amplitude); + // return extensionVector.normalize()*(force_extension[static_cast(round(length/accuracy))]); } //Gaussina force extension relation @@ -150,7 +159,7 @@ class MoveNonLinearForceEquilibrium:public MoveForceEquilibriumBase49000) + // stream.precision(std::numeric_limits::max_digits10); + // stream.setf( std::ios::fixed, std:: ios::floatfield ); + // std::cout << std::setprecision(10) + // // << setf( std::ios::fixed, std:: ios::floatfield ) + // << vec.getLength() << "\n" + // << ing.getMolecules()[Neighbors[i].ID].getVector3D()<< "\n" + // << Neighbors[i].jump<< "\n" + // << Position <<"\n" ; } shift=FE(force/(static_cast(number_of_neighbors) )); // shift2=FE(force2/(static_cast(number_of_neighbors) )); - if (ing.getMolecules().getAge()%1000 == 999 && ing.getMolecules().getAge()>49000) + // if (ing.getMolecules().getAge()%1000 == 999 && ing.getMolecules().getAge()>49000) // if(shift.getLength() > .001 ){ - std::cout << "i="<getIndex() <<" " - << shift <<" " < Date: Mon, 21 Jun 2021 11:50:10 +0200 Subject: [PATCH 25/70] clean up --- .../updater/UpdaterForceBalancedPosition.h | 20 ++-------- .../moves/MoveNonLinearForceEquilibrium.h | 40 ++----------------- 2 files changed, 6 insertions(+), 54 deletions(-) diff --git a/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h b/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h index cb89d2b..f842e84 100644 --- a/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h +++ b/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h @@ -70,39 +70,25 @@ class UpdaterForceBalancedPosition:public AbstractUpdater template bool UpdaterForceBalancedPosition::execute(){ std::cout << "UpdaterForceBalancedPosition::execute(): Start equilibration" < threshold ){ - double NSuccessfulMoves(0.); - avShift=0.0; for (uint32_t i =0 ; i0 ){ - // avShift/=(NSuccessfulMoves); - // counter=0; - // }else { - // avShift=threshold*1.1; - // counter++; - // } - // if (counter > 10 ){break;} - ing.modifyMolecules().setAge(ing.getMolecules().getAge()+1); + ing.modifyMolecules().setAge(ing.getMolecules().getAge()+1); if (ing.getMolecules().getAge() %1000 == 0 ){ std::cout << "MCS: " << ing.getMolecules().getAge() << " and average shift: " << avShift << std::endl; - // setRelaxationParameter(move.getRelaxationParameter()*factor ); } } std::cout << "Finish equilibration with average shift per cross link < " << avShift << " after " << ing.getMolecules().getAge()-StartMCS <(round(length/accuracy))])<<"\t" << "\n"; #endif - // if (length < 1 ) - // return EFGauss(extensionVector); - // if (length < 0.001 ) - // return VectorDouble3(0.,0.,0.); if (length == 0) return VectorDouble3(0.,0.,0.); auto x(length/accuracy); - auto up (static_cast(floor((length)/accuracy)+1)); - auto down(static_cast(floor(length/accuracy))); + auto up (static_cast(ceil(x)+1 )); + auto down(static_cast(floor(x))); auto amplitude=force_extension[down] + (force_extension[up]-force_extension[down])/static_cast(up-down)*(x-down)/static_cast(up-down); - // std::cout<< "amp=" << amplitude<< std::endl; - // extensionVector.normalize(); return extensionVector.normalize()*(amplitude); - // return extensionVector.normalize()*(force_extension[static_cast(round(length/accuracy))]); - } //Gaussina force extension relation //f=R*3/(N*b^2) @@ -159,7 +151,7 @@ class MoveNonLinearForceEquilibrium:public MoveForceEquilibriumBase(number_of_neighbors) )); - // shift2=FE(force2/(static_cast(number_of_neighbors) )); - // if (ing.getMolecules().getAge()%1000 == 999 && ing.getMolecules().getAge()>49000) - // if(shift.getLength() > .001 ){ - // std::cout << "i="<getIndex() <<" " - // << shift <<" " < Date: Mon, 21 Jun 2021 12:53:31 +0200 Subject: [PATCH 26/70] fix bug with average shift condition --- include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h | 5 ++++- .../updater/moves/MoveNonLinearForceEquilibrium.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h b/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h index f842e84..bb05f0f 100644 --- a/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h +++ b/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h @@ -70,7 +70,7 @@ class UpdaterForceBalancedPosition:public AbstractUpdater template bool UpdaterForceBalancedPosition::execute(){ std::cout << "UpdaterForceBalancedPosition::execute(): Start equilibration" <::execute(){ //! number of cross links auto NCrossLinks(CrossLinkIDs.size()); while (avShift > threshold ){ + double NSuccessfulMoves(0.); + avShift=0.0; for (uint32_t i =0 ; i(ceil(x)+1 )); auto down(static_cast(floor(x))); + auto up (down+1); auto amplitude=force_extension[down] + (force_extension[up]-force_extension[down])/static_cast(up-down)*(x-down)/static_cast(up-down); return extensionVector.normalize()*(amplitude); } From 3d7d2d938fc99c55567248b2e6243a310744ea1f Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Thu, 24 Jun 2021 13:00:48 +0200 Subject: [PATCH 27/70] clean up --- .../feature/FeatureCrosslinkConnectionsLookUp.h | 2 ++ .../LeMonADE_PM/updater/UpdaterForceBalancedPosition.h | 9 ++------- .../updater/moves/MoveNonLinearForceEquilibrium.h | 4 ---- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/include/LeMonADE_PM/feature/FeatureCrosslinkConnectionsLookUp.h b/include/LeMonADE_PM/feature/FeatureCrosslinkConnectionsLookUp.h index 1f38489..7c50e2c 100644 --- a/include/LeMonADE_PM/feature/FeatureCrosslinkConnectionsLookUp.h +++ b/include/LeMonADE_PM/feature/FeatureCrosslinkConnectionsLookUp.h @@ -74,11 +74,13 @@ class FeatureCrosslinkConnectionsLookUp : public Feature { //!getter function for the neighboring crosslinks std::vector getCrossLinkNeighborIDs(uint32_t CrossLinkID) const{ + #ifdef DEBUG if (CrossLinkNeighbors.find(CrossLinkID) == CrossLinkNeighbors.end()){ std::stringstream errormessage; errormessage << "FeatureCrosslinkConnectionsLookUp::getCrossLinkNeighborIDs Cross Link ID " << CrossLinkID <<" does not exist."; throw std::runtime_error(errormessage.str()); } + #endif return CrossLinkNeighbors.at(CrossLinkID); }; diff --git a/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h b/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h index bb05f0f..ed9d1ea 100644 --- a/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h +++ b/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h @@ -41,9 +41,9 @@ class UpdaterForceBalancedPosition:public AbstractUpdater public: //! constructor for UpdaterForceBalancedPosition UpdaterForceBalancedPosition(IngredientsType& ing_, double threshold_, double factor_=0.995 ): - ing(ing_),threshold(threshold_),factor(factor_),relaxationParameter(1.0){}; + ing(ing_),threshold(threshold_),relaxationParameter(1.0){}; - virtual void initialize(){relaxationParameter=move.getRelaxationParameter();}// init(move);}; + virtual void initialize(){}; bool execute(); virtual void cleanup(){}; @@ -56,10 +56,6 @@ class UpdaterForceBalancedPosition:public AbstractUpdater //! threshold for the certainty double threshold; - double relaxationParameter; - - double factor; - //! move to equilibrate the cross links by force equilibrium moveType move; @@ -72,7 +68,6 @@ bool UpdaterForceBalancedPosition::execute(){ std::cout << "UpdaterForceBalancedPosition::execute(): Start equilibration" < Date: Tue, 13 Jul 2021 10:18:01 +0200 Subject: [PATCH 28/70] comment out a check, which can only be used for integer box sizes. This is not compatible with the affine deformation. --- .../analyzer/AnalyzerEquilbratedPosition.h | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/include/LeMonADE_PM/analyzer/AnalyzerEquilbratedPosition.h b/include/LeMonADE_PM/analyzer/AnalyzerEquilbratedPosition.h index bb32639..5bcfde1 100644 --- a/include/LeMonADE_PM/analyzer/AnalyzerEquilbratedPosition.h +++ b/include/LeMonADE_PM/analyzer/AnalyzerEquilbratedPosition.h @@ -102,18 +102,18 @@ std::vector< std::vector > AnalyzerEquilbratedPosition auto neighbors(ingredients.getCrossLinkNeighborIDs(IDx)); for (size_t j=0; j < neighbors.size() ;j++){ VectorDouble3 vec(ingredients.getMolecules()[neighbors[j].ID].getVector3D()-ingredients.getMolecules()[IDx].getVector3D()-neighbors[j].jump); - VectorDouble3 vec2=LemonadeDistCalcs::MinImageVector(ingredients.getMolecules()[neighbors[j].ID].getVector3D(),ingredients.getMolecules()[IDx].getVector3D(),ingredients); - if ( vec.getLength() != vec2.getLength()) { - std::stringstream error_message; - error_message << "AnalyzerEquilbratedPosition:\n" - << "distance from jump=(" << vec << ") \n" - << "distance from IMC=(" << vec2 << ") \n" - << "jump vector=("<< neighbors[j].jump <<") \n" - << "position1=("< Date: Tue, 13 Jul 2021 10:18:56 +0200 Subject: [PATCH 29/70] add an updater which adjusts the jump vector and the positions of all monomers according to the stretching factor lambda. --- .../updater/UpdaterAffineDeformation.h | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 include/LeMonADE_PM/updater/UpdaterAffineDeformation.h diff --git a/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h b/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h new file mode 100644 index 0000000..861e37f --- /dev/null +++ b/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h @@ -0,0 +1,87 @@ +/*-------------------------------------------------------------------------------- + ooo L attice-based | + o\.|./o e xtensible | LeMonADE: An Open Source Implementation of the + o\.\|/./o Mon te-Carlo | Bond-Fluctuation-Model for Polymers +oo---0---oo A lgorithm and | + o/./|\.\o D evelopment | Copyright (C) 2013-2015 by + o/.|.\o E nvironment | LeMonADE Principal Developers (see AUTHORS) + ooo | +---------------------------------------------------------------------------------- + +This file is part of LeMonADE. + +LeMonADE 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. + +LeMonADE 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 LeMonADE. If not, see . + +--------------------------------------------------------------------------------*/ +#ifndef LEMONADE_PM_UPDATER_UPDATERAFFINEDEFORMATION_H +#define LEMONADE_PM_UPDATER_UPDATERAFFINEDEFORMATION_H + + +#include +#include +#include +#include +#include + /** + * @class UpdaterAffineDeformation + * @tparam IngredientsType + */ + + template +class UpdaterAffineDeformation:public AbstractUpdater +{ +public: + //! constructor for UpdaterAffineDeformation + UpdaterAffineDeformation(IngredientsType& ing_, double lambda_ ): + ing(ing_),lambda(lambda_),labmdaYZ(std::sqrt(labmda)){}; + + virtual void initialize(){}; + virtual bool execute(){return false;}; + virtual void cleanup(){}; + +private: + //!copy of the main container for the system informations + IngredientsType& ing; + + //! threshold for the certainty + double lambda; + double labmdaYZ; + void deform( VectorDouble3& vec ){ + vec.setAllCoordinates(vec.getX()*lambda,vec.getY()*labmdaYZ,vec.getZ()*labmdaYZ); + } +}; +template +void UpdaterAffineDeformation::initialize(){ + //adjusting the box size is not neccessary, because it is used only once in the FeatureCrosslinkConnections* + //there the jump vectors are calculated + + //The jump vector needs to be adjusted according the deformation labmda! + auto CrossLinkIDs(ing.getCrosslinkIDs()); + for (uint32_t i =0 ; i Neighbors(ing.getCrossLinkNeighborIDs(ID ); + int32_t number_of_neighbors(Neighbors.size()); + if (number_of_neighbors > 0) { + deform(Neighbors[i].jump); + } + + } + + //The initial posistions of all monomers needs to be adjusted according the deformation labmda! + for(size_t i = 0; i< myIngredients.getMolecules().size();i++){ + deform(ing.modifyMolecules()[i].modifyVector3D()); + } + return false; +} +#endif /*LEMONADE_PM_UPDATER_UPDATERAFFINEDEFORMATION_H*/ \ No newline at end of file From 0f56b8a7d38f904bd1bd121c1546adf04f115606 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Tue, 13 Jul 2021 10:22:52 +0200 Subject: [PATCH 30/70] add stdout for observing the affine deformation --- .../LeMonADE_PM/updater/UpdaterAffineDeformation.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h b/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h index 861e37f..4640d6a 100644 --- a/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h +++ b/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h @@ -63,6 +63,7 @@ class UpdaterAffineDeformation:public AbstractUpdater }; template void UpdaterAffineDeformation::initialize(){ + std::cout << "UpdaterAffineDeformation::initialize():\n"; //adjusting the box size is not neccessary, because it is used only once in the FeatureCrosslinkConnections* //there the jump vectors are calculated @@ -70,18 +71,25 @@ void UpdaterAffineDeformation::initialize(){ auto CrossLinkIDs(ing.getCrosslinkIDs()); for (uint32_t i =0 ; i Neighbors(ing.getCrossLinkNeighborIDs(ID ); int32_t number_of_neighbors(Neighbors.size()); if (number_of_neighbors > 0) { deform(Neighbors[i].jump); } - + if (i < 20 ) + std::cout << "deformed jump " << ing.getMolecules()[ID].getVector3D() << "\n"; } //The initial posistions of all monomers needs to be adjusted according the deformation labmda! for(size_t i = 0; i< myIngredients.getMolecules().size();i++){ + if (i < 20 ) + std::cout << "initial position " << ing.getMolecules()[ID].getVector3D() << " "; deform(ing.modifyMolecules()[i].modifyVector3D()); + if (i < 20 ) + std::cout << "deformed position " << ing.getMolecules()[ID].getVector3D() << "\n"; } - return false; + std::cout << "UpdaterAffineDeformation::initialize():done.\n"; } #endif /*LEMONADE_PM_UPDATER_UPDATERAFFINEDEFORMATION_H*/ \ No newline at end of file From 47d3cd20d7eb5f2e6da3ac9628b8ee83518f0cfa Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Tue, 13 Jul 2021 10:29:51 +0200 Subject: [PATCH 31/70] include the affine deformation into the force equilibration for the tendomer --- .../updater/UpdaterAffineDeformation.h | 12 ++++++----- projects/TendomerNetworkForceEquilibrium.cpp | 21 ++++++++++++------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h b/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h index 4640d6a..5920404 100644 --- a/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h +++ b/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h @@ -35,6 +35,8 @@ along with LeMonADE. If not, see . #include /** * @class UpdaterAffineDeformation + * @brief This class performs a affine deformation accordign to the stretching factor (lambda) + * for the positions and the jump vector. * @tparam IngredientsType */ @@ -43,8 +45,8 @@ class UpdaterAffineDeformation:public AbstractUpdater { public: //! constructor for UpdaterAffineDeformation - UpdaterAffineDeformation(IngredientsType& ing_, double lambda_ ): - ing(ing_),lambda(lambda_),labmdaYZ(std::sqrt(labmda)){}; + UpdaterAffineDeformation(IngredientsType& ing_, double stretching_factor_ ): + ing(ing_),stretching_factor(stretching_factor_),stretching_factor_XY(std::sqrt(stretching_factor)){}; virtual void initialize(){}; virtual bool execute(){return false;}; @@ -55,10 +57,10 @@ class UpdaterAffineDeformation:public AbstractUpdater IngredientsType& ing; //! threshold for the certainty - double lambda; - double labmdaYZ; + double stretching_factor; + double stretching_factor_XY; void deform( VectorDouble3& vec ){ - vec.setAllCoordinates(vec.getX()*lambda,vec.getY()*labmdaYZ,vec.getZ()*labmdaYZ); + vec.setAllCoordinates(vec.getX()*stretching_factor,vec.getY()*stretching_factor_XY,vec.getZ()*stretching_factor_XY); } }; template diff --git a/projects/TendomerNetworkForceEquilibrium.cpp b/projects/TendomerNetworkForceEquilibrium.cpp index cffe0b5..4e3c76d 100644 --- a/projects/TendomerNetworkForceEquilibrium.cpp +++ b/projects/TendomerNetworkForceEquilibrium.cpp @@ -53,6 +53,7 @@ along with LeMonADE. If not, see . #include #include #include +#include int main(int argc, char* argv[]){ @@ -66,16 +67,18 @@ int main(int argc, char* argv[]){ double relaxationParameter(10.); double threshold(0.5); double factor(0.995); + double stretching_factor(1.0); bool showHelp = false; auto parser - = clara::detail::Opt( inputBFM, "inputBFM (=inconfig.bfm)" ) ["-i"]["--input" ] ("(required)Input filename of the bfm file" ).required() - | clara::detail::Opt( outputDataPos, "outputDataPos (=CrosslinkPosition.dat)" ) ["-o"]["--outputPos" ] ("(optional) Output filename of the crosslink ID and the equilibrium Position.").optional() - | clara::detail::Opt( outputDataDist, "outputDataDist (=ChainExtensionDistribution.dat)") ["-c"]["--outputDist" ] ("(optional) Output filename of the chain extension distribution." ).optional() - | clara::detail::Opt( threshold, "threshold" ) ["-t"]["--threshold" ] ("(optional) Threshold of the average shift. Default 0.5 ." ).optional() - | clara::detail::Opt( feCurve, "feCurve (="")" ) ["-f"]["--feCurve" ] ("(optional) Force-Extension curve. Default \"\"." ).required() - | clara::detail::Opt( relaxationParameter, "relaxationParameter (=10)" ) ["-r"]["--relax" ] ("(optional) Relaxation parameter. Default 10.0 ." ).optional() - | clara::detail::Opt( factor, "factor (=10)" ) ["-a"]["--factor" ] ("(optional) Factor for reducing the relaxation parameter after 1000MCS. Default .995 .").optional() + = clara::detail::Opt( inputBFM, "inputBFM (=inconfig.bfm)" ) ["-i"]["--input" ] ("(required)Input filename of the bfm file" ).required() + | clara::detail::Opt( outputDataPos, "outputDataPos (=CrosslinkPosition.dat)" ) ["-o"]["--outputPos" ] ("(optional) Output filename of the crosslink ID and the equilibrium Position.").optional() + | clara::detail::Opt( outputDataDist, "outputDataDist (=ChainExtensionDistribution.dat)") ["-c"]["--outputDist" ] ("(optional) Output filename of the chain extension distribution." ).optional() + | clara::detail::Opt( threshold, "threshold" ) ["-t"]["--threshold" ] ("(optional) Threshold of the average shift. Default 0.5 ." ).optional() + | clara::detail::Opt( feCurve, "feCurve (="")" ) ["-f"]["--feCurve" ] ("(optional) Force-Extension curve. Default \"\"." ).required() + | clara::detail::Opt( relaxationParameter, "relaxationParameter (=10)" ) ["-r"]["--relax" ] ("(optional) Relaxation parameter. Default 10.0 ." ).optional() + | clara::detail::Opt( factor, "factor (=10)" ) ["-a"]["--factor" ] ("(optional) Factor for reducing the relaxation parameter after 1000MCS. Default .995 .").optional() + | clara::detail::Opt( stretching_factor, "stretching_factor (=1)" ) ["-l"]["--stretching_factor"] ("(optional) Stretching factor for uniaxial deformation. Default 1.0 ." ).optional() | clara::Help( showHelp ); auto result = parser.parse( clara::Args( argc, argv ) ); @@ -93,7 +96,8 @@ int main(int argc, char* argv[]){ std::cout << "inputBFM : " << inputBFM << std::endl; std::cout << "threshold : " << threshold << std::endl; std::cout << "feCurve : " << feCurve << std::endl; - std::cout << "factor : " << factor << std::endl; + std::cout << "factor : " << factor << std::endl; + std::cout << "stretching_factor : " << stretching_factor << std::endl; } RandomNumberGenerators rng; rng.seedAll(); @@ -148,6 +152,7 @@ int main(int argc, char* argv[]){ myIngredients2.synchronize(); TaskManager taskmanager2; + taskmanager2.addUpdater( new UpdaterAffineDeformation(myIngredients2, stretching_factor) ); //read bonds and positions stepwise auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold, factor) ; updater->setFilename(feCurve); From d374f3c70cd1a66375fc313ac31def2833a7fe30 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Tue, 13 Jul 2021 10:34:48 +0200 Subject: [PATCH 32/70] it compiles. --- .../LeMonADE_PM/updater/UpdaterAffineDeformation.h | 12 ++++++------ .../updater/UpdaterForceBalancedPosition.h | 2 +- projects/TendomerNetworkForceEquilibrium.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h b/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h index 5920404..f4a3a43 100644 --- a/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h +++ b/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h @@ -48,7 +48,7 @@ class UpdaterAffineDeformation:public AbstractUpdater UpdaterAffineDeformation(IngredientsType& ing_, double stretching_factor_ ): ing(ing_),stretching_factor(stretching_factor_),stretching_factor_XY(std::sqrt(stretching_factor)){}; - virtual void initialize(){}; + virtual void initialize(); virtual bool execute(){return false;}; virtual void cleanup(){}; @@ -74,8 +74,8 @@ void UpdaterAffineDeformation::initialize(){ for (uint32_t i =0 ; i Neighbors(ing.getCrossLinkNeighborIDs(ID ); + std::cout << "ID="<< i << "initial jump " << ing.getMolecules()[ID].getVector3D() << " "; + std::vector Neighbors(ing.getCrossLinkNeighborIDs(ID) ); int32_t number_of_neighbors(Neighbors.size()); if (number_of_neighbors > 0) { deform(Neighbors[i].jump); @@ -85,12 +85,12 @@ void UpdaterAffineDeformation::initialize(){ } //The initial posistions of all monomers needs to be adjusted according the deformation labmda! - for(size_t i = 0; i< myIngredients.getMolecules().size();i++){ + for(size_t i = 0; i< ing.getMolecules().size();i++){ if (i < 20 ) - std::cout << "initial position " << ing.getMolecules()[ID].getVector3D() << " "; + std::cout << "ID="<< i << "initial position " << ing.getMolecules()[i].getVector3D() << " "; deform(ing.modifyMolecules()[i].modifyVector3D()); if (i < 20 ) - std::cout << "deformed position " << ing.getMolecules()[ID].getVector3D() << "\n"; + std::cout << "deformed position " << ing.getMolecules()[i].getVector3D() << "\n"; } std::cout << "UpdaterAffineDeformation::initialize():done.\n"; } diff --git a/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h b/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h index ed9d1ea..f328243 100644 --- a/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h +++ b/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h @@ -41,7 +41,7 @@ class UpdaterForceBalancedPosition:public AbstractUpdater public: //! constructor for UpdaterForceBalancedPosition UpdaterForceBalancedPosition(IngredientsType& ing_, double threshold_, double factor_=0.995 ): - ing(ing_),threshold(threshold_),relaxationParameter(1.0){}; + ing(ing_),threshold(threshold_){}; virtual void initialize(){}; bool execute(); diff --git a/projects/TendomerNetworkForceEquilibrium.cpp b/projects/TendomerNetworkForceEquilibrium.cpp index 4e3c76d..09fde2c 100644 --- a/projects/TendomerNetworkForceEquilibrium.cpp +++ b/projects/TendomerNetworkForceEquilibrium.cpp @@ -152,7 +152,7 @@ int main(int argc, char* argv[]){ myIngredients2.synchronize(); TaskManager taskmanager2; - taskmanager2.addUpdater( new UpdaterAffineDeformation(myIngredients2, stretching_factor) ); + taskmanager2.addUpdater( new UpdaterAffineDeformation(myIngredients2, stretching_factor) ); //read bonds and positions stepwise auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold, factor) ; updater->setFilename(feCurve); From b3a07c7d13d53d9c6f7f06a2149c4ae4df53d37c Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Tue, 13 Jul 2021 11:26:03 +0200 Subject: [PATCH 33/70] rewrite deform function --- include/LeMonADE_PM/updater/UpdaterAffineDeformation.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h b/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h index f4a3a43..273154c 100644 --- a/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h +++ b/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h @@ -59,13 +59,13 @@ class UpdaterAffineDeformation:public AbstractUpdater //! threshold for the certainty double stretching_factor; double stretching_factor_XY; - void deform( VectorDouble3& vec ){ - vec.setAllCoordinates(vec.getX()*stretching_factor,vec.getY()*stretching_factor_XY,vec.getZ()*stretching_factor_XY); + VectorDouble3 deform( VectorDouble3 vec ){ + return VectorDouble3(vec.getX()*stretching_factor,vec.getY()*stretching_factor_XY,vec.getZ()*stretching_factor_XY); } }; template void UpdaterAffineDeformation::initialize(){ - std::cout << "UpdaterAffineDeformation::initialize():\n"; + std::cout << "UpdaterAffineDeformation::initialize():"<< std::endl; //adjusting the box size is not neccessary, because it is used only once in the FeatureCrosslinkConnections* //there the jump vectors are calculated @@ -78,7 +78,7 @@ void UpdaterAffineDeformation::initialize(){ std::vector Neighbors(ing.getCrossLinkNeighborIDs(ID) ); int32_t number_of_neighbors(Neighbors.size()); if (number_of_neighbors > 0) { - deform(Neighbors[i].jump); + Neighbors[i].jump)= deform(Neighbors[i].jump); } if (i < 20 ) std::cout << "deformed jump " << ing.getMolecules()[ID].getVector3D() << "\n"; @@ -88,7 +88,7 @@ void UpdaterAffineDeformation::initialize(){ for(size_t i = 0; i< ing.getMolecules().size();i++){ if (i < 20 ) std::cout << "ID="<< i << "initial position " << ing.getMolecules()[i].getVector3D() << " "; - deform(ing.modifyMolecules()[i].modifyVector3D()); + ing.modifyMolecules()[i].modifyVector3D()=deform(ing.modifyMolecules()[i].getVector3D()); if (i < 20 ) std::cout << "deformed position " << ing.getMolecules()[i].getVector3D() << "\n"; } From 2cf38c58d008c3269766e7d7cd072e9d2852cbb3 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Tue, 13 Jul 2021 11:26:03 +0200 Subject: [PATCH 34/70] rewrite deform function --- include/LeMonADE_PM/updater/UpdaterAffineDeformation.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h b/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h index f4a3a43..5153081 100644 --- a/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h +++ b/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h @@ -59,13 +59,13 @@ class UpdaterAffineDeformation:public AbstractUpdater //! threshold for the certainty double stretching_factor; double stretching_factor_XY; - void deform( VectorDouble3& vec ){ - vec.setAllCoordinates(vec.getX()*stretching_factor,vec.getY()*stretching_factor_XY,vec.getZ()*stretching_factor_XY); + VectorDouble3 deform( VectorDouble3 vec ){ + return VectorDouble3(vec.getX()*stretching_factor,vec.getY()*stretching_factor_XY,vec.getZ()*stretching_factor_XY); } }; template void UpdaterAffineDeformation::initialize(){ - std::cout << "UpdaterAffineDeformation::initialize():\n"; + std::cout << "UpdaterAffineDeformation::initialize():"<< std::endl; //adjusting the box size is not neccessary, because it is used only once in the FeatureCrosslinkConnections* //there the jump vectors are calculated @@ -78,7 +78,7 @@ void UpdaterAffineDeformation::initialize(){ std::vector Neighbors(ing.getCrossLinkNeighborIDs(ID) ); int32_t number_of_neighbors(Neighbors.size()); if (number_of_neighbors > 0) { - deform(Neighbors[i].jump); + Neighbors[i].jump= deform(Neighbors[i].jump); } if (i < 20 ) std::cout << "deformed jump " << ing.getMolecules()[ID].getVector3D() << "\n"; @@ -88,7 +88,7 @@ void UpdaterAffineDeformation::initialize(){ for(size_t i = 0; i< ing.getMolecules().size();i++){ if (i < 20 ) std::cout << "ID="<< i << "initial position " << ing.getMolecules()[i].getVector3D() << " "; - deform(ing.modifyMolecules()[i].modifyVector3D()); + ing.modifyMolecules()[i].modifyVector3D()=deform(ing.modifyMolecules()[i].getVector3D()); if (i < 20 ) std::cout << "deformed position " << ing.getMolecules()[i].getVector3D() << "\n"; } From 01ba7dd8f843d3282c872c8acc6fdd97819dfa52 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Tue, 13 Jul 2021 11:37:40 +0200 Subject: [PATCH 35/70] fix bug: indexing of the jump vector --- include/LeMonADE_PM/updater/UpdaterAffineDeformation.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h b/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h index 5153081..7f8c38c 100644 --- a/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h +++ b/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h @@ -73,15 +73,13 @@ void UpdaterAffineDeformation::initialize(){ auto CrossLinkIDs(ing.getCrosslinkIDs()); for (uint32_t i =0 ; i Neighbors(ing.getCrossLinkNeighborIDs(ID) ); int32_t number_of_neighbors(Neighbors.size()); if (number_of_neighbors > 0) { - Neighbors[i].jump= deform(Neighbors[i].jump); + for (size_t j = 0; j < number_of_neighbors; j++){ + Neighbors[j].jump= deform(Neighbors[j].jump); + } } - if (i < 20 ) - std::cout << "deformed jump " << ing.getMolecules()[ID].getVector3D() << "\n"; } //The initial posistions of all monomers needs to be adjusted according the deformation labmda! From 6c27dbd12376469d30945cd47ac8e53e306c0e5b Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Tue, 13 Jul 2021 11:39:59 +0200 Subject: [PATCH 36/70] adjust stretching factor for the y and z direction --- include/LeMonADE_PM/updater/UpdaterAffineDeformation.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h b/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h index 7f8c38c..36c006c 100644 --- a/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h +++ b/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h @@ -46,7 +46,7 @@ class UpdaterAffineDeformation:public AbstractUpdater public: //! constructor for UpdaterAffineDeformation UpdaterAffineDeformation(IngredientsType& ing_, double stretching_factor_ ): - ing(ing_),stretching_factor(stretching_factor_),stretching_factor_XY(std::sqrt(stretching_factor)){}; + ing(ing_),stretching_factor(stretching_factor_),stretching_factor_XY(1./std::sqrt(stretching_factor)){}; virtual void initialize(); virtual bool execute(){return false;}; From 7c04346faea35c5ae25c36d5c8f12b9bce5cfe4e Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Tue, 13 Jul 2021 12:07:06 +0200 Subject: [PATCH 37/70] workaournd for overstretched configs in the beginning. --- include/LeMonADE_PM/updater/UpdaterAffineDeformation.h | 6 +++++- .../updater/moves/MoveNonLinearForceEquilibrium.h | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h b/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h index 36c006c..32aecf3 100644 --- a/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h +++ b/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h @@ -77,7 +77,11 @@ void UpdaterAffineDeformation::initialize(){ int32_t number_of_neighbors(Neighbors.size()); if (number_of_neighbors > 0) { for (size_t j = 0; j < number_of_neighbors; j++){ - Neighbors[j].jump= deform(Neighbors[j].jump); + if (i < 20 ) + std::cout << "ID= "<< i << "initial jump " << Neighbors[j].jump << " "; + Neighbors[j].jump= deform(Neighbors[j].jump); + if (i < 20 ) + std::cout << "ID= "<< i << "defrormed jump " << Neighbors[j].jump << "\n"; } } } diff --git a/include/LeMonADE_PM/updater/moves/MoveNonLinearForceEquilibrium.h b/include/LeMonADE_PM/updater/moves/MoveNonLinearForceEquilibrium.h index a1a242a..58d5a44 100644 --- a/include/LeMonADE_PM/updater/moves/MoveNonLinearForceEquilibrium.h +++ b/include/LeMonADE_PM/updater/moves/MoveNonLinearForceEquilibrium.h @@ -84,7 +84,9 @@ class MoveNonLinearForceEquilibrium:public MoveForceEquilibriumBasegetIndex()].getVector3D()); for (size_t i = 0; i < number_of_neighbors; i++){ VectorDouble3 vec(ing.getMolecules()[Neighbors[i].ID].getVector3D()-Neighbors[i].jump-Position); + // std::cout << ing.getMolecules()[Neighbors[i].ID].getVector3D() << " " << Neighbors[i].jump<< " " << Position <(number_of_neighbors) )); From d018657d4ac4eb0e2822eb9e3687b615eafa230a Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Wed, 14 Jul 2021 10:20:46 +0200 Subject: [PATCH 38/70] erase bug in the transformation of the jump vector --- ...FeatureCrosslinkConnectionsLookUpTendomers.h | 10 ++++++++++ .../updater/UpdaterAffineDeformation.h | 17 +++++++++++------ .../updater/moves/MoveForceEquilibrium.h | 1 + .../moves/MoveNonLinearForceEquilibrium.h | 2 +- projects/TendomerNetworkForceEquilibrium.cpp | 11 ++++++----- 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/include/LeMonADE_PM/feature/FeatureCrosslinkConnectionsLookUpTendomers.h b/include/LeMonADE_PM/feature/FeatureCrosslinkConnectionsLookUpTendomers.h index 409aae0..67b6f42 100644 --- a/include/LeMonADE_PM/feature/FeatureCrosslinkConnectionsLookUpTendomers.h +++ b/include/LeMonADE_PM/feature/FeatureCrosslinkConnectionsLookUpTendomers.h @@ -82,6 +82,16 @@ class FeatureCrosslinkConnectionsLookUpTendomers : public Feature { return CrossLinkNeighbors.at(CrossLinkID); }; + //! set the jump vector + void setCrossLinkNeighborJump(uint32_t CrossLinkID, uint32_t idx, VectorDouble3 vec) { + if ( idx > CrossLinkNeighbors.at(CrossLinkID).size() ){ + std::stringstream errormessage; + errormessage << "FeatureCrosslinkConnectionsLookUpTendomers::setCrossLinkNeighborJump neighbor idx " << idx <<" is to high."; + throw std::runtime_error(errormessage.str()); + } + CrossLinkNeighbors.at(CrossLinkID)[idx].jump=vec; + } + //!get the ID of crosslinks (determined by nConnections>3 and connected to another crosslink) const std::vector& getCrosslinkIDs() const {return crosslinkIDs;} diff --git a/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h b/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h index 32aecf3..d4fdc84 100644 --- a/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h +++ b/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h @@ -46,7 +46,11 @@ class UpdaterAffineDeformation:public AbstractUpdater public: //! constructor for UpdaterAffineDeformation UpdaterAffineDeformation(IngredientsType& ing_, double stretching_factor_ ): - ing(ing_),stretching_factor(stretching_factor_),stretching_factor_XY(1./std::sqrt(stretching_factor)){}; + ing(ing_),stretching_factor(stretching_factor_),stretching_factor_XY(1./std::sqrt(stretching_factor)){ + std::cout << "UpdaterAffineDeformation::constructor:\n" + << "stretching factor = " << stretching_factor << "\n" + << "stretching factor in yz = " << stretching_factor_XY << "\n"; + }; virtual void initialize(); virtual bool execute(){return false;}; @@ -60,6 +64,7 @@ class UpdaterAffineDeformation:public AbstractUpdater double stretching_factor; double stretching_factor_XY; VectorDouble3 deform( VectorDouble3 vec ){ + return VectorDouble3(vec.getX()*stretching_factor,vec.getY()*stretching_factor_XY,vec.getZ()*stretching_factor_XY); } }; @@ -78,10 +83,10 @@ void UpdaterAffineDeformation::initialize(){ if (number_of_neighbors > 0) { for (size_t j = 0; j < number_of_neighbors; j++){ if (i < 20 ) - std::cout << "ID= "<< i << "initial jump " << Neighbors[j].jump << " "; - Neighbors[j].jump= deform(Neighbors[j].jump); + std::cout << "ID= "<< i << " initial jump " << Neighbors[j].jump << " "; + ing.setCrossLinkNeighborJump(ID,j,deform(Neighbors[j].jump)); if (i < 20 ) - std::cout << "ID= "<< i << "defrormed jump " << Neighbors[j].jump << "\n"; + std::cout << "ID= "<< i << " defromed jump " << Neighbors[j].jump << "\n"; } } } @@ -90,9 +95,9 @@ void UpdaterAffineDeformation::initialize(){ for(size_t i = 0; i< ing.getMolecules().size();i++){ if (i < 20 ) std::cout << "ID="<< i << "initial position " << ing.getMolecules()[i].getVector3D() << " "; - ing.modifyMolecules()[i].modifyVector3D()=deform(ing.modifyMolecules()[i].getVector3D()); + ing.modifyMolecules()[i].modifyVector3D()=deform(ing.getMolecules()[i].getVector3D()); if (i < 20 ) - std::cout << "deformed position " << ing.getMolecules()[i].getVector3D() << "\n"; + std::cout << " deformed position " << ing.getMolecules()[i].getVector3D() << "\n"; } std::cout << "UpdaterAffineDeformation::initialize():done.\n"; } diff --git a/include/LeMonADE_PM/updater/moves/MoveForceEquilibrium.h b/include/LeMonADE_PM/updater/moves/MoveForceEquilibrium.h index d3e669b..47bd8c0 100644 --- a/include/LeMonADE_PM/updater/moves/MoveForceEquilibrium.h +++ b/include/LeMonADE_PM/updater/moves/MoveForceEquilibrium.h @@ -96,6 +96,7 @@ class MoveForceEquilibrium:public MoveForceEquilibriumBase VectorDouble3 vec(ing.getMolecules()[Neighbors[i].ID].getVector3D()-Position-Neighbors[i].jump); avNSegments+=1./Neighbors[i].segDistance; force+=FE(vec,Neighbors[i].segDistance); + // std::cout <<"MoveLFE " << ing.getMolecules()[Neighbors[i].ID].getVector3D() << "\t" << Neighbors[i].jump<< "\t" << Position << "\t" << vec << "\t" << force << std::endl; } shift=EF(force,1./avNSegments); } diff --git a/include/LeMonADE_PM/updater/moves/MoveNonLinearForceEquilibrium.h b/include/LeMonADE_PM/updater/moves/MoveNonLinearForceEquilibrium.h index 58d5a44..7ac4771 100644 --- a/include/LeMonADE_PM/updater/moves/MoveNonLinearForceEquilibrium.h +++ b/include/LeMonADE_PM/updater/moves/MoveNonLinearForceEquilibrium.h @@ -167,7 +167,7 @@ class MoveNonLinearForceEquilibrium:public MoveForceEquilibriumBasegetIndex()].getVector3D()); for (size_t i = 0; i < number_of_neighbors; i++){ VectorDouble3 vec(ing.getMolecules()[Neighbors[i].ID].getVector3D()-Neighbors[i].jump-Position); - // std::cout << ing.getMolecules()[Neighbors[i].ID].getVector3D() << " " << Neighbors[i].jump<< " " << Position <(number_of_neighbors) )); diff --git a/projects/TendomerNetworkForceEquilibrium.cpp b/projects/TendomerNetworkForceEquilibrium.cpp index 09fde2c..3417a28 100644 --- a/projects/TendomerNetworkForceEquilibrium.cpp +++ b/projects/TendomerNetworkForceEquilibrium.cpp @@ -100,6 +100,7 @@ int main(int argc, char* argv[]){ std::cout << "stretching_factor : " << stretching_factor << std::endl; } RandomNumberGenerators rng; + // rng.seedDefaultValuesAll(); rng.seedAll(); /////////////////////////////////////////////////////////////////////////////// ///end options parsing @@ -152,12 +153,12 @@ int main(int argc, char* argv[]){ myIngredients2.synchronize(); TaskManager taskmanager2; - taskmanager2.addUpdater( new UpdaterAffineDeformation(myIngredients2, stretching_factor) ); + taskmanager2.addUpdater( new UpdaterAffineDeformation(myIngredients2, stretching_factor),0 ); //read bonds and positions stepwise - auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold, factor) ; - updater->setFilename(feCurve); - updater->setRelaxationParameter(relaxationParameter); - // auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; + // auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold, factor) ; + // updater->setFilename(feCurve); + // updater->setRelaxationParameter(relaxationParameter); + auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; taskmanager2.addUpdater( updater ); taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,outputDataPos, outputDataDist)); //initialize and run From b78e6831237210e4118aaa2330e8df412f4b943c Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Fri, 16 Jul 2021 14:41:16 +0200 Subject: [PATCH 39/70] comment in the Tendomer specific force eq --- .../updater/UpdaterForceBalancedPosition.h | 2 +- projects/TendomerNetworkForceEquilibrium.cpp | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h b/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h index f328243..6cb956e 100644 --- a/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h +++ b/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h @@ -40,7 +40,7 @@ class UpdaterForceBalancedPosition:public AbstractUpdater { public: //! constructor for UpdaterForceBalancedPosition - UpdaterForceBalancedPosition(IngredientsType& ing_, double threshold_, double factor_=0.995 ): + UpdaterForceBalancedPosition(IngredientsType& ing_, double threshold_ ): ing(ing_),threshold(threshold_){}; virtual void initialize(){}; diff --git a/projects/TendomerNetworkForceEquilibrium.cpp b/projects/TendomerNetworkForceEquilibrium.cpp index 3417a28..06694c2 100644 --- a/projects/TendomerNetworkForceEquilibrium.cpp +++ b/projects/TendomerNetworkForceEquilibrium.cpp @@ -68,6 +68,8 @@ int main(int argc, char* argv[]){ double threshold(0.5); double factor(0.995); double stretching_factor(1.0); + bool gauss(false); + bool langevin(false); bool showHelp = false; auto parser @@ -75,10 +77,11 @@ int main(int argc, char* argv[]){ | clara::detail::Opt( outputDataPos, "outputDataPos (=CrosslinkPosition.dat)" ) ["-o"]["--outputPos" ] ("(optional) Output filename of the crosslink ID and the equilibrium Position.").optional() | clara::detail::Opt( outputDataDist, "outputDataDist (=ChainExtensionDistribution.dat)") ["-c"]["--outputDist" ] ("(optional) Output filename of the chain extension distribution." ).optional() | clara::detail::Opt( threshold, "threshold" ) ["-t"]["--threshold" ] ("(optional) Threshold of the average shift. Default 0.5 ." ).optional() + | clara::detail::Opt( stretching_factor, "stretching_factor (=1)" ) ["-l"]["--stretching_factor"] ("(optional) Stretching factor for uniaxial deformation. Default 1.0 ." ).optional() | clara::detail::Opt( feCurve, "feCurve (="")" ) ["-f"]["--feCurve" ] ("(optional) Force-Extension curve. Default \"\"." ).required() | clara::detail::Opt( relaxationParameter, "relaxationParameter (=10)" ) ["-r"]["--relax" ] ("(optional) Relaxation parameter. Default 10.0 ." ).optional() - | clara::detail::Opt( factor, "factor (=10)" ) ["-a"]["--factor" ] ("(optional) Factor for reducing the relaxation parameter after 1000MCS. Default .995 .").optional() - | clara::detail::Opt( stretching_factor, "stretching_factor (=1)" ) ["-l"]["--stretching_factor"] ("(optional) Stretching factor for uniaxial deformation. Default 1.0 ." ).optional() + | clara::detail::Opt( gauss, "gauss" ) ["-g"]["--gauss" ] ("(optional) Deforma with a Gaussian deformation behaviour. Default 1.0 ." ).optional() + | clara::detail::Opt( langevin, "langevin" ) ["-v"]["--langevin" ] ("(optional) Deforma with a Langevin deformation behaviour. Default 1.0 ." ).optional() | clara::Help( showHelp ); auto result = parser.parse( clara::Args( argc, argv ) ); @@ -96,7 +99,8 @@ int main(int argc, char* argv[]){ std::cout << "inputBFM : " << inputBFM << std::endl; std::cout << "threshold : " << threshold << std::endl; std::cout << "feCurve : " << feCurve << std::endl; - std::cout << "factor : " << factor << std::endl; + std::cout << "gauss : " << gauss << std::endl; + std::cout << "Langevin : " << langevin << std::endl; std::cout << "stretching_factor : " << stretching_factor << std::endl; } RandomNumberGenerators rng; @@ -155,10 +159,10 @@ int main(int argc, char* argv[]){ TaskManager taskmanager2; taskmanager2.addUpdater( new UpdaterAffineDeformation(myIngredients2, stretching_factor),0 ); //read bonds and positions stepwise - // auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold, factor) ; - // updater->setFilename(feCurve); - // updater->setRelaxationParameter(relaxationParameter); - auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; + auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; + updater->setFilename(feCurve); + updater->setRelaxationParameter(relaxationParameter); + // auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; taskmanager2.addUpdater( updater ); taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,outputDataPos, outputDataDist)); //initialize and run From 26cfeab2388de83951690647ce2780ae7afe1644 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Mon, 19 Jul 2021 10:35:54 +0200 Subject: [PATCH 40/70] Correct output of the uniaxial transformation. --- .../LeMonADE_PM/updater/UpdaterAffineDeformation.h | 2 +- projects/TendomerNetworkForceEquilibrium.cpp | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h b/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h index d4fdc84..4629f78 100644 --- a/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h +++ b/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h @@ -86,7 +86,7 @@ void UpdaterAffineDeformation::initialize(){ std::cout << "ID= "<< i << " initial jump " << Neighbors[j].jump << " "; ing.setCrossLinkNeighborJump(ID,j,deform(Neighbors[j].jump)); if (i < 20 ) - std::cout << "ID= "<< i << " defromed jump " << Neighbors[j].jump << "\n"; + std::cout << "ID= "<< i << " deformed jump " << ing.getCrossLinkNeighborIDs(ID)[j].jump << "\n"; } } } diff --git a/projects/TendomerNetworkForceEquilibrium.cpp b/projects/TendomerNetworkForceEquilibrium.cpp index 06694c2..dd4c413 100644 --- a/projects/TendomerNetworkForceEquilibrium.cpp +++ b/projects/TendomerNetworkForceEquilibrium.cpp @@ -69,7 +69,6 @@ int main(int argc, char* argv[]){ double factor(0.995); double stretching_factor(1.0); bool gauss(false); - bool langevin(false); bool showHelp = false; auto parser @@ -81,7 +80,6 @@ int main(int argc, char* argv[]){ | clara::detail::Opt( feCurve, "feCurve (="")" ) ["-f"]["--feCurve" ] ("(optional) Force-Extension curve. Default \"\"." ).required() | clara::detail::Opt( relaxationParameter, "relaxationParameter (=10)" ) ["-r"]["--relax" ] ("(optional) Relaxation parameter. Default 10.0 ." ).optional() | clara::detail::Opt( gauss, "gauss" ) ["-g"]["--gauss" ] ("(optional) Deforma with a Gaussian deformation behaviour. Default 1.0 ." ).optional() - | clara::detail::Opt( langevin, "langevin" ) ["-v"]["--langevin" ] ("(optional) Deforma with a Langevin deformation behaviour. Default 1.0 ." ).optional() | clara::Help( showHelp ); auto result = parser.parse( clara::Args( argc, argv ) ); @@ -100,7 +98,6 @@ int main(int argc, char* argv[]){ std::cout << "threshold : " << threshold << std::endl; std::cout << "feCurve : " << feCurve << std::endl; std::cout << "gauss : " << gauss << std::endl; - std::cout << "Langevin : " << langevin << std::endl; std::cout << "stretching_factor : " << stretching_factor << std::endl; } RandomNumberGenerators rng; @@ -162,8 +159,14 @@ int main(int argc, char* argv[]){ auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; updater->setFilename(feCurve); updater->setRelaxationParameter(relaxationParameter); - // auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; - taskmanager2.addUpdater( updater ); + auto updater2 = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; + if ( gauss == 0 ){ + std::cout << "TendomerNetworkForceEquilibrium: add UpdaterForceBalancedPosition(myIngredients2, threshold) \n"; + taskmanager2.addUpdater( updater ); + }else { + std::cout << "TendomerNetworkForceEquilibrium: add UpdaterForceBalancedPosition(myIngredients2, threshold) \n"; + taskmanager2.addUpdater( updater2 ); + } taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,outputDataPos, outputDataDist)); //initialize and run taskmanager2.initialize(); From 30eca51f0db0dfb1761c9ccda2943823487b6653 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Mon, 30 Aug 2021 09:51:52 +0200 Subject: [PATCH 41/70] modify the force equilibration for the standard end linked networks --- .../updater/UpdaterReadCrosslinkConnections.h | 59 +++++---- projects/CMakeLists.txt | 4 + projects/ForceEquilibrium.cpp | 10 +- .../NetworkWritePartialConnectedNetwork.cpp | 114 ++++++++++++++++++ 4 files changed, 156 insertions(+), 31 deletions(-) create mode 100644 projects/NetworkWritePartialConnectedNetwork.cpp diff --git a/include/LeMonADE_PM/updater/UpdaterReadCrosslinkConnections.h b/include/LeMonADE_PM/updater/UpdaterReadCrosslinkConnections.h index de40361..8bbedf6 100644 --- a/include/LeMonADE_PM/updater/UpdaterReadCrosslinkConnections.h +++ b/include/LeMonADE_PM/updater/UpdaterReadCrosslinkConnections.h @@ -92,7 +92,7 @@ class UpdaterReadCrosslinkConnections : public AbstractUpdater uint32_t nExecutions; //! connects the cross link to the chain - void ConnectCrossLinkToChain(uint32_t MonID, uint32_t chainID); + bool ConnectCrossLinkToChain(uint32_t MonID, uint32_t chainID); //!bond Table std::map,std::vector > bondTable; @@ -100,18 +100,31 @@ class UpdaterReadCrosslinkConnections : public AbstractUpdater template -void UpdaterReadCrosslinkConnections::ConnectCrossLinkToChain(uint32_t MonID, uint32_t chainID){ +bool UpdaterReadCrosslinkConnections::ConnectCrossLinkToChain(uint32_t MonID, uint32_t chainID){ + // std::pair key(MonID,chainID-1); + // if (bondTable.find(key) != bondTable.end()){ + // if ( !ing.getMolecules().areConnected( MonID,bondTable.at(key)[0] ) ) + // ing.modifyMolecules().connect(MonID,bondTable.at(key)[0] ); + // else + // ing.modifyMolecules().connect(MonID,bondTable.at(key)[1] ); + // }else{ + // std::stringstream errormessage; + // errormessage << "There was no such a connection in the bfm file for monomer ID= " << MonID << " with chainID=" << chainID-1<< "\n"; + // throw std::runtime_error(errormessage.str()); + // } std::pair key(MonID,chainID-1); if (bondTable.find(key) != bondTable.end()){ - if ( !ing.getMolecules().areConnected( MonID,bondTable.at(key)[0] ) ) + if ( !ing.getMolecules().areConnected( MonID,bondTable.at(key)[0] ) ){ ing.modifyMolecules().connect(MonID,bondTable.at(key)[0] ); - else + return true ; + } + //chain can only have one neighbor (without this statement a more or less random partner would be connected to the structure !!) + if ( bondTable.at(key).size()>1 ) { ing.modifyMolecules().connect(MonID,bondTable.at(key)[1] ); - }else{ - std::stringstream errormessage; - errormessage << "There was no such a connection in the bfm file for monomer ID= " << MonID << " with chainID=" << chainID-1<< "\n"; - throw std::runtime_error(errormessage.str()); + return true ; + } } + return false; } /** @@ -153,18 +166,6 @@ bool UpdaterReadCrosslinkConnections::execute(){ stream.open(input); if (stream.fail()) throw std::runtime_error(std::string("error opening input file ") + input + std::string("\n")); - bool findStartofData(false); - //set head to beginning of the data block - while (!findStartofData){ - std::string line; - getline(stream, line); - if (line.empty()) - findStartofData = true; - else if (line.at(0) == '#') //go to next line - continue; - else - throw std::runtime_error("Wrong input format!"); - } //current conversion auto conversion = minConversion + static_cast(nExecutions) * stepwidth; std::cout << "Current conversion is " <::execute(){ while (NewConnections < ReadNLines && stream.good()){ std::string line; getline(stream, line); - if (line.empty()) + if (line.empty() || line.at(0) == '#') break; std::stringstream ss; uint32_t Time, ChainID, MonID1, P1X, P1Y, P1Z, MonID2, P2X, P2Y, P2Z; ss << line; ss >> Time >> ChainID >> MonID1 >> P1X >> P1Y >> P1Z >> MonID2 >> P2X >> P2Y >> P2Z; - // if (NewConnections == 0 ) - // std::cout << Time << " " << ChainID<< " " - // << MonID1<< " " << P1X << " " << P1Y << " " << P1Z << " " - // << MonID2<< " " << P2X << " " << P2Y << " " << P2Z << "\n"; + #ifdef DEBUG + std::cout << ss.str() << std::endl; + #endif //DEBUG// ing.modifyMolecules().setAge(Time); - ConnectCrossLinkToChain(MonID1, ChainID); + // ConnectCrossLinkToChain(MonID1, ChainID); + if ( ConnectCrossLinkToChain(MonID1, ChainID+1) ) { + }else if( ConnectCrossLinkToChain(MonID2, ChainID+1) ) { + }else { + std::stringstream errormessage; + errormessage << "There was no such a connection in the bfm file for monomer ID= " << MonID1 <<" with ID=" << MonID2 << " with chainID=" << ChainID<< "\n"; + throw std::runtime_error(errormessage.str()); + } //update positions : I think this is not needed // ing.modifyMolecules()[MonID1].modifyVector3D().setAllCoordinates(P1X, P1Y, P1Z); // if (MonID2 > 0) diff --git a/projects/CMakeLists.txt b/projects/CMakeLists.txt index 9bc852b..b1ddda1 100644 --- a/projects/CMakeLists.txt +++ b/projects/CMakeLists.txt @@ -1,6 +1,8 @@ add_executable(ForceEquilibrium ForceEquilibrium.cpp) target_link_libraries(ForceEquilibrium LeMonADE CommandlineParser ) +add_executable(NetworkWritePartialConnectedNetwork NetworkWritePartialConnectedNetwork.cpp) +target_link_libraries(NetworkWritePartialConnectedNetwork LeMonADE CommandlineParser ) add_executable(TendomerNetworkForceEquilibrium TendomerNetworkForceEquilibrium.cpp) target_link_libraries(TendomerNetworkForceEquilibrium LeMonADE CommandlineParser ) @@ -14,5 +16,7 @@ target_link_libraries(TendomerNetworkExtractGelPart LeMonADE CommandlineParser ) add_executable(TendomerNetworkWritePartialConnectedNetwork TendomerNetworkWritePartialConnectedNetwork.cpp) target_link_libraries(TendomerNetworkWritePartialConnectedNetwork LeMonADE CommandlineParser ) + + # add_executable(IntramolecularReactions IntramolecularReactions.cpp) # target_link_libraries(IntramolecularReactions LeMonADE CommandlineParser ) \ No newline at end of file diff --git a/projects/ForceEquilibrium.cpp b/projects/ForceEquilibrium.cpp index 9325f4a..e92e1fd 100644 --- a/projects/ForceEquilibrium.cpp +++ b/projects/ForceEquilibrium.cpp @@ -61,7 +61,7 @@ int main(int argc, char* argv[]){ std::string inputBFM("init.bfm"); std::string outputDataPos("CrosslinkPosition.dat"); std::string outputDataDist("ChainExtensionDistribution.dat"); - std::string inputConnection("BondCreationBreaking.dat"); + // std::string inputConnection("BondCreationBreaking.dat"); std::string feCurve; double relaxationParameter(10.); double threshold(0.5); @@ -72,7 +72,7 @@ int main(int argc, char* argv[]){ bool showHelp = false; auto parser = clara::detail::Opt( inputBFM, "inputBFM (=inconfig.bfm)" ) ["-i"]["--input" ] ("(required)Input filename of the bfm file" ).required() - | clara::detail::Opt( inputConnection, "inputConnection (=BondCreationBreaking.dat)" ) ["-d"]["--inputConnection"] ("used for the time development of the topology. " ).required() + // | clara::detail::Opt( inputConnection, "inputConnection (=BondCreationBreaking.dat)" ) ["-d"]["--inputConnection"] ("used for the time development of the topology. " ).required() | clara::detail::Opt( outputDataPos, "outputDataPos (=CrosslinkPosition.dat)" ) ["-o"]["--outputPos" ] ("(optional) Output filename of the crosslink ID and the equilibrium Position.").optional() | clara::detail::Opt( outputDataDist, "outputDataDist (=ChainExtensionDistribution.dat)") ["-c"]["--outputDist" ] ("(optional) Output filename of the chain extension distribution." ).optional() | clara::detail::Opt( stepwidth, "stepwidth" ) ["-s"]["--stepwidth" ] ("(optional) Width for the increase in percentage. Default: 1%." ).optional() @@ -95,7 +95,7 @@ int main(int argc, char* argv[]){ std::cout << "outputData : " << outputDataPos << std::endl; std::cout << "outputDataDist : " << outputDataDist << std::endl; std::cout << "inputBFM : " << inputBFM << std::endl; - std::cout << "inputConnection : " << inputConnection << std::endl; + // std::cout << "inputConnection : " << inputConnection << std::endl; std::cout << "stepwidth : " << stepwidth << std::endl; std::cout << "minConversion : " << minConversion << std::endl; std::cout << "threshold : " << threshold << std::endl; @@ -161,7 +161,7 @@ int main(int argc, char* argv[]){ if(custom){ TaskManager taskmanager2; //read bonds and positions stepwise - taskmanager2.addUpdater( new UpdaterReadCrosslinkConnections(myIngredients2, inputConnection, stepwidth, minConversion) ); + // taskmanager2.addUpdater( new UpdaterReadCrosslinkConnections(myIngredients2, inputConnection, stepwidth, minConversion) ); std::cout << "Use custom force-extension curve\n"; auto forceUpdater = new UpdaterForceBalancedPosition(myIngredients2, threshold); forceUpdater->setFilename(feCurve); @@ -175,7 +175,7 @@ int main(int argc, char* argv[]){ } else { TaskManager taskmanager2; //read bonds and positions stepwise - taskmanager2.addUpdater( new UpdaterReadCrosslinkConnections(myIngredients2, inputConnection, stepwidth, minConversion) ); + // taskmanager2.addUpdater( new UpdaterReadCrosslinkConnections(myIngredients2, inputConnection, stepwidth, minConversion) ); std::cout << "Use gaussian force-extension relation\n"; auto forceUpdater = new UpdaterForceBalancedPosition(myIngredients2, threshold); taskmanager2.addUpdater( forceUpdater ); diff --git a/projects/NetworkWritePartialConnectedNetwork.cpp b/projects/NetworkWritePartialConnectedNetwork.cpp new file mode 100644 index 0000000..0d95711 --- /dev/null +++ b/projects/NetworkWritePartialConnectedNetwork.cpp @@ -0,0 +1,114 @@ +/*-------------------------------------------------------------------------------- + ooo L attice-based | + o\.|./o e xtensible | LeMonADE: An Open Source Implementation of the + o\.\|/./o Mon te-Carlo | Bond-Fluctuation-Model for Polymers +oo---0---oo A lgorithm and | + o/./|\.\o D evelopment | Copyright (C) 2013-2015 by + o/.|.\o E nvironment | LeMonADE Principal Developers (see AUTHORS) + ooo | +---------------------------------------------------------------------------------- + +This file is part of LeMonADE. + +LeMonADE 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. + +LeMonADE 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 LeMonADE. If not, see . + +--------------------------------------------------------------------------------*/ + +/****************************************************************************** + * based on LeMonADE: https://github.com/LeMonADE-project/LeMonADE/ + * author: Toni Müller + * email: mueller-toni@ipfdd.de + * project: LeMonADE-Phantom Modulus + *****************************************************************************/ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + + +int main(int argc, char* argv[]){ + try{ + /////////////////////////////////////////////////////////////////////////////// + ///parse options/// + std::string inputBFM("init.bfm"); + std::string outputBFM("Config.bfm.dat"); + std::string inputConnection("BondCreationBreaking.dat"); + bool showHelp = false; + auto parser + = clara::detail::Opt( inputBFM, "inputBFM (=inconfig.bfm)" ) ["-i"]["--input" ] ("(required)Input filename of the bfm file" ).required() + | clara::detail::Opt( inputConnection, "inputConnection (=BondCreationBreaking.dat)" ) ["-d"]["--inputConnection" ] ("used for the time development of the topology. " ).required() + | clara::detail::Opt( outputBFM, "outputBFM (=Config.bfm)" ) ["-o"]["--outputBFM" ] ("Output filename for the active material of the tendomer network.") + | clara::Help( showHelp ); + + auto result = parser.parse( clara::Args( argc, argv ) ); + + if( !result ) { + std::cerr << "Error in command line: " << result.errorMessage() << std::endl; + exit(1); + }else if(showHelp == true){ + std::cout << "Analyzer taking a bond table and a table specifying the activity of an object and writes the active part of the tendoemr network."<< std::endl; + std::cout << "Important: input file for the connections and the active material must fit to each other!!!"<< std::endl; + parser.writeToStream(std::cout); + exit(0); + }else{ + std::cout << "outputBFM : " << outputBFM << std::endl; + std::cout << "inputBFM : " << inputBFM << std::endl; + std::cout << "inputConnection : " << inputConnection << std::endl; + } + /////////////////////////////////////////////////////////////////////////////// + ///end options parsing + /////////////////////////////////////////////////////////////////////////////// + typedef LOKI_TYPELIST_4(FeatureMoleculesIOUnsaveCheck, FeatureReactiveBonds, FeatureAttributes<>,FeatureSystemInformationLinearMeltWithCrosslinker) Features; + typedef ConfigureSystem Config; + typedef Ingredients Ing; + Ing myIngredients; + + TaskManager taskmanager; + + taskmanager.addUpdater( new UpdaterReadBfmFile(inputBFM,myIngredients, UpdaterReadBfmFile::READ_LAST_CONFIG_SAVE),0); + taskmanager.addUpdater( new UpdaterReadCrosslinkConnections(myIngredients, inputConnection, 0., 1.0) ); + taskmanager.addAnalyzer( new AnalyzerWriteBfmFile(outputBFM, myIngredients, 1) ); + //initialize and run + taskmanager.initialize(); + taskmanager.run(1); + taskmanager.cleanup(); + std::cout << "Read in conformation and go on to bring it into equilibrium forces..." < Date: Fri, 15 Oct 2021 12:51:26 +0200 Subject: [PATCH 42/70] add a molecular weight analyzer --- .../analyzer/AnalyzerMolecularWeight.h | 129 ++++++++++++++++++ projects/AnalyzeMolecularWeight.cpp | 104 ++++++++++++++ projects/CMakeLists.txt | 3 +- 3 files changed, 235 insertions(+), 1 deletion(-) create mode 100644 include/LeMonADE_PM/analyzer/AnalyzerMolecularWeight.h create mode 100644 projects/AnalyzeMolecularWeight.cpp diff --git a/include/LeMonADE_PM/analyzer/AnalyzerMolecularWeight.h b/include/LeMonADE_PM/analyzer/AnalyzerMolecularWeight.h new file mode 100644 index 0000000..e13a979 --- /dev/null +++ b/include/LeMonADE_PM/analyzer/AnalyzerMolecularWeight.h @@ -0,0 +1,129 @@ +/*-------------------------------------------------------------------------------- + ooo L attice-based | + o\.|./o e xtensible | LeMonADE: An Open Source Implementation of the + o\.\|/./o Mon te-Carlo | Bond-Fluctuation-Model for Polymers +oo---0---oo A lgorithm and | + o/./|\.\o D evelopment | Copyright (C) 2013-2015 by + o/.|.\o E nvironment | LeMonADE Principal Developers (see AUTHORS) + ooo | +---------------------------------------------------------------------------------- + +This file is part of LeMonADE. + +LeMonADE 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. + +LeMonADE 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 LeMonADE. If not, see . + +--------------------------------------------------------------------------------*/ + +#ifndef LEMONADE_PM_ANALYZER_MOLECULAR_WEIGTH_H +#define LEMONADE_PM_ANALYZER_MOLECULAR_WEIGTH_H + +#include + +#include +#include +#include +#include +#include +#include + + +/************************************************************************* + * definition of AnalyzerMolecularWeight class + * ***********************************************************************/ + +/** + * @file + * + * @class AnalyzerMolecularWeight + * + * @tparam IngredientsType Ingredients class storing all system information( e.g. monomers, bonds, etc). + * + * @details Calculates the number and weight averaged molecular weight. + * + */ +template < class IngredientsType > +class AnalyzerMolecularWeight : public AnalyzerAbstractDump +{ + typedef AnalyzerAbstractDump BaseClass; +private: + //! typedef for the underlying container holding the monomers + typedef typename IngredientsType::molecules_type molecules_type; + + std::string basename; + +protected: + using BaseClass::ingredients; + using BaseClass::Data; + using BaseClass::MCSTimes; + using BaseClass::dumpTimeSeries; + +public: + //! constructor + AnalyzerMolecularWeight(const IngredientsType& ing, std::string fileSuffix_); + //! destructor. does nothing + virtual ~AnalyzerMolecularWeight(){} + //! calculate the moleculare weight distribution + virtual void initialize(); + virtual bool execute(); +}; + +/************************************************************************* + * implementation of memebers + * ***********************************************************************/ + +/** + * @param ing reference to the object holding all information of the system + * @param fileSuffix output file name. defaults to "Rg2TimeSeries.dat". + * */ +template +AnalyzerMolecularWeight::AnalyzerMolecularWeight( + const IngredientsType& ing,std::string fileSuffix_) +:BaseClass(ing,fileSuffix_) {} + +template +void AnalyzerMolecularWeight::initialize() +{ + basename=BaseClass::getOutputFilename() ; + BaseClass::setBufferSize(1); + BaseClass::setNumberOfColumns(1); + execute(); +} +template< class IngredientsType > +bool AnalyzerMolecularWeight::execute() +{ + double conversion = ingredients.getConversion(); + std::stringstream comment; + comment << "Created by AnalyzerMolecularWeight\n" + << "conversion=" << conversion << "%"; + BaseClass::setComment(comment.str()); + + //calculate the molecular weight distribution + std::vector > groups; + fill_connected_groups(ingredients.getMolecules(), groups, MonomerGroup(ingredients.getMolecules()), alwaysTrue()); + //key is the size of the molecule and the value is the number of occurence + std::map dist; + for (auto it=groups.begin(); it!=groups.end();it++ ) + dist[it->size()]++; + for ( auto& it : dist ) + { + Data[0].push_back(it.second); + MCSTimes.push_back(it.first); + } + std::stringstream output; + output << "MolecularWeight_c" << conversion << basename<< ".dat"; + BaseClass::resetIsFirstFileDump(); + BaseClass::setOutputFilename(output.str()); + dumpTimeSeries(); +} +#endif diff --git a/projects/AnalyzeMolecularWeight.cpp b/projects/AnalyzeMolecularWeight.cpp new file mode 100644 index 0000000..b3b519f --- /dev/null +++ b/projects/AnalyzeMolecularWeight.cpp @@ -0,0 +1,104 @@ +/*-------------------------------------------------------------------------------- + ooo L attice-based | + o\.|./o e xtensible | LeMonADE: An Open Source Implementation of the + o\.\|/./o Mon te-Carlo | Bond-Fluctuation-Model for Polymers +oo---0---oo A lgorithm and | + o/./|\.\o D evelopment | Copyright (C) 2013-2015 by + o/.|.\o E nvironment | LeMonADE Principal Developers (see AUTHORS) + ooo | +---------------------------------------------------------------------------------- + +This file is part of LeMonADE. + +LeMonADE 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. + +LeMonADE 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 LeMonADE. If not, see . + +--------------------------------------------------------------------------------*/ + +/****************************************************************************** + * based on LeMonADE: https://github.com/LeMonADE-project/LeMonADE/ + * author: Toni Müller + * email: mueller-toni@ipfdd.de + * project: LeMonADE-Phantom Modulus + *****************************************************************************/ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + + +int main(int argc, char* argv[]){ + try{ + /////////////////////////////////////////////////////////////////////////////// + ///parse options/// + std::string inputBFM("init.bfm"); + std::string suffix("MolecularWeight.dat"); + bool showHelp = false; + auto parser + = clara::detail::Opt( inputBFM, "inputBFM (=inconfig.bfm)" ) ["-i"]["--input" ] ("(required)Input filename of the bfm file").required() + | clara::detail::Opt( suffix, "suffix (=MolecularWeight.dat)" ) ["-o"]["--suffix" ] ("suffix name for data." ).required() + | clara::Help( showHelp ); + + auto result = parser.parse( clara::Args( argc, argv ) ); + + if( !result ) { + std::cerr << "Error in command line: " << result.errorMessage() << std::endl; + exit(1); + }else if(showHelp == true){ + parser.writeToStream(std::cout); + exit(0); + }else{ + std::cout << "inputBFM : " << inputBFM << std::endl; + std::cout << "suffix : " << suffix << std::endl; + + } + /////////////////////////////////////////////////////////////////////////////// + ///end options parsing + /////////////////////////////////////////////////////////////////////////////// + typedef LOKI_TYPELIST_2(FeatureMoleculesIOUnsaveCheck, FeatureReactiveBonds) Features; + typedef ConfigureSystem Config; + typedef Ingredients Ing; + Ing ingredients; + + TaskManager taskmanager; + + taskmanager.addUpdater( new UpdaterReadBfmFile(inputBFM,ingredients, UpdaterReadBfmFile::READ_LAST_CONFIG_SAVE),0); + taskmanager.addAnalyzer( new AnalyzerMolecularWeight(ingredients, suffix) ); + //initialize and run + taskmanager.initialize(); + taskmanager.run(); + taskmanager.cleanup(); + std::cout << "Read in conformation and go on to bring it into equilibrium forces..." < Date: Fri, 15 Oct 2021 16:48:07 +0200 Subject: [PATCH 43/70] start adding a start creator --- include/LeMonADE_PM/updater/UpdaterAddStars.h | 197 ++++++++++++++++++ projects/CMakeLists.txt | 3 + projects/IdealReferenceForceEquilibrium.cpp | 188 +++++++++++++++++ 3 files changed, 388 insertions(+) create mode 100644 include/LeMonADE_PM/updater/UpdaterAddStars.h create mode 100644 projects/IdealReferenceForceEquilibrium.cpp diff --git a/include/LeMonADE_PM/updater/UpdaterAddStars.h b/include/LeMonADE_PM/updater/UpdaterAddStars.h new file mode 100644 index 0000000..4ee111f --- /dev/null +++ b/include/LeMonADE_PM/updater/UpdaterAddStars.h @@ -0,0 +1,197 @@ +/*-------------------------------------------------------------------------------- + ooo L attice-based | + o\.|./o e xtensible | LeMonADE: An Open Source Implementation of the + o\.\|/./o Mon te-Carlo | Bond-Fluctuation-Model for Polymers +oo---0---oo A lgorithm and | + o/./|\.\o D evelopment | Copyright (C) 2013-2015 by + o/.|.\o E nvironment | LeMonADE Principal Developers + ooo | +---------------------------------------------------------------------------------- + +This file is part of LeMonADE. + +LeMonADE 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. + +LeMonADE 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 LeMonADE. If not, see . + +--------------------------------------------------------------------------------*/ + +#ifndef LEMONADE_UPDATER_SETUP_STARSAB +#define LEMONADE_UPDATER_SETUP_STARSAB +/** + * @file + * + * @class UpdaterAddStars + * + * @brief Updater to create a solution of monodisperse branched stars. + * + * @details This is a simple implementation of a system setup starting from an empty ingredients + * or a system with some monomers inside. This updater requires FeatureAttributes. + * Two tags are added to the monomers in alternating manner, usually needed for GPU computing. // not realized in this first attempt + * // RS, 05 Nov 2019, but presumably 29 July 2020 + * + * @tparam IngredientsType + * + * @param ingredients_ The system, holding either an empty simulation box for system setup + * or a prefilled ingredients where the stars shall be added + * @param NStar_ number of stars that are added to ingredients + * @param NMonoPerStar_ number of monomers in each star + * @param NMonoPerBranch_ number of monomers in each branch (excluding central monomer) + * @param NBranchPerStar_ number of branches in each star + * @param type1_ attribute tag of "even" monomers + * @param type2_ attribute tag of "odd" monomers + **/ + +#include +#include +#include + +template +class UpdaterAddStars: public UpdaterAbstractCreate +{ + typedef UpdaterAbstractCreate BaseClass; + +public: + UpdaterAddStars(IngredientsType& ingredients_, uint32_t NStar_, + uint32_t NMonoPerBranch_, uint32_t NBranchPerStar_); + + virtual void initialize(); + virtual bool execute(); + virtual void cleanup(); + + //! getter function for write compressed solvent bool + const bool getIsSolvent() const {return IsSolvent;} + + //! getter function for number of stars + const int32_t getNStar() const {return NStar;} + + //! getter function for number of monomers in branch + const int32_t getNMonoPerBranch() const {return NMonoPerBranch;} + + //! getter function for number of branches in stars + const int32_t getNBranchPerStar() const {return NBranchPerStar;} + + //! getter function for calculated density + const double getDensity() const {return density;} + +private: + // provide access to functions of UpdaterAbstractCreate used in this updater + using BaseClass::ingredients; + using BaseClass::addMonomerToParent; + using BaseClass::addSingleMonomer; + using BaseClass::linearizeSystem; + + //! number of stars in the box + uint32_t NStar; + + //! number of monomers in a branch + uint32_t NMonoPerBranch; + + //! number of branches in a star + uint32_t NBranchPerStar; + + //! lattice occupation density + double density; + + //! bool for execution + bool wasExecuted; +}; + +/** +* @brief Constructor handling the new systems paramters +* +* @param ingredients_ a reference to the IngredientsType - mainly the system +* @param NStar_ number of stars to be added in the system instead of solvent +* @param NBranchPerStar_ number of branches in each star +* @param NMonoPerBranch_ number of monomers in each branch (excluding central monomer) +*/ + + +template < class IngredientsType > +UpdaterAddStars::UpdaterAddStars( + IngredientsType& ingredients_, + uint32_t NStar_, + uint32_t NMonoPerBranch_, + uint32_t NBranchPerStar_ + ): + BaseClass(ingredients_), NStar(NStar_), NMonoPerBranch(NMonoPerBranch_), NBranchPerStar(NBranchPerStar_), + density(0.0), wasExecuted(false), + {} + +/** +* @brief initialise function, calculate the target density to compare with at the end. +* +* @tparam IngredientsType Features used in the system. See Ingredients. +*/ +template < class IngredientsType > +void UpdaterAddStars::initialize(){ + std::cout << "initialize UpdaterAddStars" << std::endl; + + // get the target density from the sum of existing monomers and the new added chains + density=(double)( ingredients.getMolecules().size() + (NMonoPerBranch*NBranchPerStar+1) *NStar ) * 8 /(double)( ingredients.getBoxX()*ingredients.getBoxY()*ingredients.getBoxZ() ); + + std::cout << "add "< +bool UpdaterAddStars::execute(){ + if(wasExecuted) return true; + std::cout << "execute UpdaterAddStars" << std::endl; + //loop over stars and star monomers and build it up + uint32_t gen; + uint32_t index_center; + + for(uint32_t i=0;i<(NStar);i++){ + addSingleMonomer(1); + for(uint32_t j=0;j<(NBranchPerStar);j++){ + for(uint32_t b=0;b<(NMonoPerBranch);b++){ + u_int32_t parentID; + if (b==0) + parentID = (ingredients.getMolecules().size()-NBranchPerStar) + addMonomerToParent(parentID,1); + } + } + } + + ingredients.synchronize(); + double lattice_volume(ingredients.getBoxX()*ingredients.getBoxY()*ingredients.getBoxZ()); + if(std::abs(density - ( (double)(ingredients.getMolecules().size()*8) / lattice_volume )) > 0.0000000001 ){ + std::cout << density << " " <<( (ingredients.getMolecules().size()*8) / lattice_volume)< Config; + typedef Ingredients Ing; + Ing myIngredients; + + TaskManager taskmanager; + + taskmanager.addUpdater( new UpdaterAddStars(inputBFM,myIngredients, UpdaterReadBfmFile::READ_LAST_CONFIG_SAVE),0); + + //initialize and run + taskmanager.initialize(); + taskmanager.run(1); + taskmanager.cleanup(); + std::cout << "Read in conformation and go on to bring it into equilibrium forces..." < Config2; + typedef Ingredients Ing2; + Ing2 myIngredients2; + + myIngredients2.setBoxX(myIngredients.getBoxX()); + myIngredients2.setBoxY(myIngredients.getBoxY()); + myIngredients2.setBoxZ(myIngredients.getBoxZ()); + myIngredients2.setPeriodicX(myIngredients.isPeriodicX()); + myIngredients2.setPeriodicY(myIngredients.isPeriodicY()); + myIngredients2.setPeriodicZ(myIngredients.isPeriodicZ()); + myIngredients2.modifyMolecules().resize(myIngredients.getMolecules().size()); + myIngredients2.modifyMolecules().setAge(myIngredients.getMolecules().getAge()); + + myIngredients2.setNumTendomers (myIngredients.getNumTendomers()); + myIngredients2.setNumCrossLinkers (myIngredients.getNumCrossLinkers()); + myIngredients2.setNumMonomersPerChain (myIngredients.getNumMonomersPerChain()); + myIngredients2.setNumLabelsPerTendomerArm(myIngredients.getNumLabelsPerTendomerArm()); + + for(size_t i = 0; i< myIngredients.getMolecules().size();i++){ + myIngredients2.modifyMolecules()[i].modifyVector3D()=myIngredients.getMolecules()[i].getVector3D(); + myIngredients2.modifyMolecules()[i].setReactive(myIngredients.getMolecules()[i].isReactive()); + myIngredients2.modifyMolecules()[i].setNumMaxLinks(myIngredients.getMolecules()[i].getNumMaxLinks()); + for (size_t j = 0 ; j < myIngredients.getMolecules().getNumLinks(i);j++){ + uint32_t neighbor(myIngredients.getMolecules().getNeighborIdx(i,j)); + if( ! myIngredients2.getMolecules().areConnected(i,neighbor) ) + myIngredients2.modifyMolecules().connect(i,neighbor); + } + } + myIngredients2.synchronize(); + + TaskManager taskmanager2; + taskmanager2.addUpdater( new UpdaterAffineDeformation(myIngredients2, stretching_factor),0 ); + //read bonds and positions stepwise + auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; + updater->setFilename(feCurve); + updater->setRelaxationParameter(relaxationParameter); + auto updater2 = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; + if ( gauss == 0 ){ + std::cout << "TendomerNetworkForceEquilibrium: add UpdaterForceBalancedPosition(myIngredients2, threshold) \n"; + taskmanager2.addUpdater( updater ); + }else { + std::cout << "TendomerNetworkForceEquilibrium: add UpdaterForceBalancedPosition(myIngredients2, threshold) \n"; + taskmanager2.addUpdater( updater2 ); + } + taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,outputDataPos, outputDataDist)); + //initialize and run + taskmanager2.initialize(); + taskmanager2.run(); + taskmanager2.cleanup(); + + } + catch(std::exception& e){ + std::cerr<<"Error:\n" + < Date: Sat, 30 Oct 2021 16:53:29 +0200 Subject: [PATCH 44/70] change the star creation to use all available bonds from the bond vector set --- .../UpdaterAbstractCreateAllBondVectors.h | 533 ++++++++++++++++++ include/LeMonADE_PM/updater/UpdaterAddStars.h | 25 +- projects/IdealReferenceForceEquilibrium.cpp | 85 ++- 3 files changed, 602 insertions(+), 41 deletions(-) create mode 100644 include/LeMonADE_PM/updater/UpdaterAbstractCreateAllBondVectors.h diff --git a/include/LeMonADE_PM/updater/UpdaterAbstractCreateAllBondVectors.h b/include/LeMonADE_PM/updater/UpdaterAbstractCreateAllBondVectors.h new file mode 100644 index 0000000..9616749 --- /dev/null +++ b/include/LeMonADE_PM/updater/UpdaterAbstractCreateAllBondVectors.h @@ -0,0 +1,533 @@ +/*-------------------------------------------------------------------------------- + ooo L attice-based | + o\.|./o e xtensible | LeMonADE: An Open Source Implementation of the + o\.\|/./o Mon te-Carlo | Bond-Fluctuation-Model for Polymers +oo---0---oo A lgorithm and | + o/./|\.\o D evelopment | Copyright (C) 2016 by + o/.|.\o E nvironment | LeMonADE Principal Developers + ooo | +---------------------------------------------------------------------------------- + +This file is part of LeMonADE. + +LeMonADE 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. + +LeMonADE 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 LeMonADE. If not, see . + +--------------------------------------------------------------------------------*/ +#ifndef LEMONADEPM_UPDATER_UPDATERABSTRACTCREATEALLBONDS_H +#define LEMONADEPM_UPDATER_UPDATERABSTRACTCREATEALLBONDS_H + + +/** + * @file + * + * @class UpdaterAbstractCreateAllBonds + * + * @brief abstract updater to create systems + * + * @details This abstract class provides the three basic functions to create systems: add a single monomer, add a connected monomer and move the system to find some free space. + * This Updater requires FeatureAttributes. + * + * @tparam IngredientsType + * + **/ + +#include +#include +#include +#include +#include +#include + +template +class UpdaterAbstractCreateAllBonds:public AbstractUpdater +{ +public: + UpdaterAbstractCreateAllBonds(IngredientsType& ingredients_):ingredients(ingredients_),lookupFilled(false){} + + virtual void initialize(); + virtual bool execute(); + virtual void cleanup(); + +protected: + IngredientsType& ingredients; + + //! function to add a standalone monomer + bool addSingleMonomer(int32_t type=1); + + //! function to add a monomer to a parent monomer + bool addMonomerToParent(uint32_t parent_id, int32_t type=1); + + //! function to add a monomer at a spezific place + bool addMonomerAtPosition(VectorInt3 pos, int32_t type=1); + + //! function to add a new monomer inbetween two others + bool addMonomerInsideConnectedPair(uint32_t indexA, uint32_t indexB, int32_t type=1); + + //! function to add a new monomer at two others + bool addMonomerAtConnectedPair(uint32_t indexA, uint32_t indexB, int32_t type=1); + + //! function to add a ring around a chain monomer + bool addRing(uint32_t parent_id, int32_t type=1, uint32_t NRingMonomers=5); + + //! function to move the whole system + void moveSystem(int32_t nsteps); + + //! function to find groups of connected monomers + void linearizeSystem(); + + //! function to get a random bondvector of length 2 + VectorInt3 randomBondvector(); + +private: + RandomNumberGenerators rng; + + //! bond table is filled with all valid bonds or not + bool lookupFilled; + //!set of vectors which are valid for the conformations + std::vector bondvectorSet; + +}; + +/** +* The initialize function handles the new systems information. +* +* @tparam IngredientsType Features used in the system. See Ingredients. +*/ +template < class IngredientsType > +void UpdaterAbstractCreateAllBonds::initialize(){ + +} + +/** +* Execution of the system creation +* +* @tparam IngredientsType Features used in the system. See Ingredients. +*/ +template < class IngredientsType > +bool UpdaterAbstractCreateAllBonds::execute(){ + +} + +/** +* Standard clean up. +* +* @tparam IngredientsType Features used in the system. See Ingredients. +*/ +template < class IngredientsType > +void UpdaterAbstractCreateAllBonds::cleanup(){ + +} + +/******************************************************************************/ +/** + * @brief function to add a standalone monomer + * @param type attribute tag of the new monomer + * @return if position is not free, if move was applied + */ +template +bool UpdaterAbstractCreateAllBonds::addSingleMonomer(int32_t type){ + // set properties of add Monomer Move + MoveAddMonomerSc<> addmove; + addmove.init(ingredients); + addmove.setTag(type); + + int32_t counter(0); + while(counter<10000){ + VectorInt3 newPosition((rng.r250_rand32() % (ingredients.getBoxX()-1)), + (rng.r250_rand32() % (ingredients.getBoxY()-1)), + (rng.r250_rand32() % (ingredients.getBoxZ()-1))); + addmove.setPosition(newPosition); + if(addmove.check(ingredients)==true){ + addmove.apply(ingredients); + return true; + } + counter++; + } + return false; +} + +/******************************************************************************/ +/** + * @brief function to add a monomer to a parent monomer + * @param parent_id id of monomer to connect with + * @param type attribute tag of the new monomer + * @return if position is not free, if move was applied + */ +template +bool UpdaterAbstractCreateAllBonds::addMonomerToParent(uint32_t parent_id, int32_t type){ + // set properties of add Monomer Move + MoveAddMonomerSc<> addmove; + addmove.init(ingredients); + addmove.setTag(type); + + int32_t counter(0); + + while(counter<10000){ + //try at most 30 random bondvectors to find a new monomer position + for(uint i=0;i<30;i++){ + VectorInt3 bondvector(randomBondvector()); + // set position of new monomer + addmove.setPosition(ingredients.getMolecules()[parent_id]+bondvector); + + // check new position (excluded volume) + if(addmove.check(ingredients)==true){ + addmove.apply(ingredients); + ingredients.modifyMolecules().connect( parent_id, (ingredients.getMolecules().size()-1) ); + return true; + } + } + // if no position matches, we need to move the system a bit + moveSystem(2); + counter++; + } + return false; +} + +/******************************************************************************/ +/** + * @brief function to add a monomer to a specific position. if position is not free return false + * @param VectorInt3 position + * @param type attribute tag of the new monomer + * @return if position is not free, if move was applied + */ +template +bool UpdaterAbstractCreateAllBonds::addMonomerAtPosition(VectorInt3 position, int32_t type){ + MoveAddMonomerSc<> addmove; + addmove.init(ingredients); + addmove.setTag(type); + + addmove.setPosition(position); + if(addmove.check(ingredients)==true){ + addmove.apply(ingredients); + return true; + }else{ + return false; + } +} + +/******************************************************************************/ +/** + * @brief function to add a new monomer between two already existing ones instead of a bond. + * @param indexA + * @param indexB + * @param type attribute tag of the new monomer + * @return if position is not free, if move was applied + */ +template +bool UpdaterAbstractCreateAllBonds::addMonomerInsideConnectedPair(uint32_t indexA, uint32_t indexB, int32_t type){ + //first check if monomers are connected + if( ! ingredients.getMolecules().areConnected(indexA,indexB)) + return false; + + MoveAddMonomerSc<> addmove; + addmove.init(ingredients); + addmove.setTag(type); + + int32_t counter(0); + + while(counter<10000){ + //try at most 30 random bondvectors to find a new monomer position + for(uint i=0;i<30;i++){ + // get a random bondvector + VectorInt3 bondvector(randomBondvector()); + // set position of new monomer + addmove.setPosition(ingredients.getMolecules()[indexA]+bondvector); + + // check new position (excluded volume, other features) + if(addmove.check(ingredients)==true){ + //check the new bondvector bewten the new monomer and indexB + VectorInt3 checkBV(addmove.getPosition()-ingredients.getMolecules()[indexB]); + if( (checkBV.getLength() < 3) && (ingredients.getBondset().isValidStrongCheck(checkBV)) ){ + addmove.apply(ingredients); + ingredients.modifyMolecules().connect( indexA, (ingredients.getMolecules().size()-1) ); + ingredients.modifyMolecules().connect( indexB, (ingredients.getMolecules().size()-1) ); + ingredients.modifyMolecules().disconnect( indexA, indexB ); + return true; + } + } + } + // if no position matches, we need to move the system a bit + moveSystem(2); + counter++; + } + return false; +} +/******************************************************************************/ +/** + * @brief function to add a new monomer to two already existing ones such that all three monomers are connected. + * @param indexA + * @param indexB + * @param type attribute tag of the new monomer + * @return if position is not free, if move was applied + */ +template +bool UpdaterAbstractCreateAllBonds::addMonomerAtConnectedPair(uint32_t indexA, uint32_t indexB, int32_t type){ + //first check if monomers are connected + if( ! ingredients.getMolecules().areConnected(indexA,indexB)) + return false; + + MoveAddMonomerSc<> addmove; + addmove.init(ingredients); + addmove.setTag(type); + + int32_t counter(0); + + while(counter<10000){ + //try at most 30 random bondvectors to find a new monomer position + for(uint i=0;i<30;i++){ + // get a random bondvector + VectorInt3 bondvector(randomBondvector()); + // set position of new monomer + addmove.setPosition(ingredients.getMolecules()[indexA]+bondvector); + + // check new position (excluded volume, other features) + if(addmove.check(ingredients)==true){ + //check the new bondvector between the new monomer and indexB + VectorInt3 checkBV(addmove.getPosition()-ingredients.getMolecules()[indexB]); + if( (checkBV.getLength() < 3) && (ingredients.getBondset().isValidStrongCheck(checkBV)) ){ + addmove.apply(ingredients); + ingredients.modifyMolecules().connect( indexA, (ingredients.getMolecules().size()-1) ); + ingredients.modifyMolecules().connect( indexB, (ingredients.getMolecules().size()-1) ); + return true; + } + } + } + // if no position matches, we need to move the system a bit + moveSystem(2); + counter++; + } + return false; +} +/** + * @brief add a ring threaded on a chain at position of parent monomer + * + * @todo are there conformations where bonds of the ring cross the bonds of the chain? + * + * @param parent + * @param type monomer tag + * @param NRingMonomers number of monomers per ring + */ +template < class IngredientsType > +bool UpdaterAbstractCreateAllBonds::addRing(uint32_t parent, int32_t type, uint32_t NRingMonomers) + { + if(parent < ingredients.getMolecules().size()) + { + uint32_t attempts(0); + while (attempts<10000) + { + uint32_t neighborDirection(0); + uint32_t currentParent(parent); + while (true) + { + uint32_t neighborID(ingredients.getMolecules().getNeighborIdx(currentParent,neighborDirection)); + if(ingredients.getMolecules().getNumLinks(neighborID) != 2 ) + { + if(neighborDirection==1) break; + else {neighborDirection++; currentParent=parent;} + } + else + { + VectorInt3 neighborPosition(ingredients.getMolecules()[neighborID]); + VectorInt3 parentPosition(ingredients.getMolecules()[currentParent]); + VectorInt3 bond(neighborPosition-parentPosition); + uint32_t otherParentNeighbor; + uint32_t otherNeighborNeighbor; + neighborDirection ? otherParentNeighbor=(ingredients.getMolecules().getNeighborIdx(currentParent,0)) : otherParentNeighbor=(ingredients.getMolecules().getNeighborIdx(currentParent,1)); + (ingredients.getMolecules().getNeighborIdx(neighborID,0)==currentParent) ? otherNeighborNeighbor=(ingredients.getMolecules().getNeighborIdx(neighborID,1)): otherNeighborNeighbor=(ingredients.getMolecules().getNeighborIdx(neighborID,0)); + VectorInt3 neighborParentBond(parentPosition-ingredients.getMolecules()[otherParentNeighbor]); + VectorInt3 neighborNeighborBond(neighborPosition-ingredients.getMolecules()[otherNeighborNeighbor]); + if(bond.getLength() == 2 && (neighborParentBond.getLength()<3) &&(neighborNeighborBond.getLength()<3)) + { + for(uint32_t i=0; i<8; i++) + { + + VectorInt3 StartPosition=parentPosition; + //set the possible conformations + int32_t dx1, dx2; + int32_t dy1, dz1; + int32_t dy2, dz2; + VectorInt3 vec1,vec2; + if(bond.getX() == 2 || bond.getX() == -2) + { + StartPosition+=VectorInt3(bond.getX()/2,0,0); + dx1=0;dx2=0;//dy1=2;dy2=0;dz1=0;dz2=2; + if(rng.r250_drand()>0.5){dy1=2;dy2=0;dz1=0;dz2=2;} + else {dy1=0;dy2=2;dz1=2;dz2=0;} + int32_t dx3,dx4; + if(rng.r250_drand()>0.5){dx3=1;dx4=-1;} + else{dx3=-1;dx4=1;} +// rng.r250_drand()>0.5 ? dx3=1 : dx3=-1; +// rng.r250_drand()>0.5 ? dx4=1 : dx4=-1; + vec1=VectorInt3( dx2+dx3, dy2, dz2); + vec2=VectorInt3(-dx2+dx4, -dy2, -dz2); + } + else if(bond.getY() == 2 || bond.getY() == -2) + { + StartPosition+=VectorInt3(0,bond.getY()/2,0); + dy1=0;dy2=0; + if(rng.r250_drand()>0.5){dx1=2;dx2=0;dz1=0;dz2=2;} + else {dx1=0;dx2=2;dz1=2;dz2=0;} + int32_t dy3,dy4; + if(rng.r250_drand()>0.5){dy3=1;dy4=-1;} + else{dy3=-1;dy4=1;} +// rng.r250_drand()>0.5 ? dy3=1 : dy3=-1; +// rng.r250_drand()>0.5 ? dy4=1 : dy4=-1; + vec1=VectorInt3( dx2, dy2+dy3, dz2); + vec2=VectorInt3(-dx2, -dy2+dy4, -dz2); + } + else if(bond.getZ() == 2 || bond.getZ() == -2) + { + StartPosition+=VectorInt3(0,0,bond.getZ()/2); + dz1=0;dz2=0; + if(rng.r250_drand()>0.5){dx1=2;dx2=0;dy1=0;dy2=2;} + else {dx1=0;dx2=2;dy1=2;dy2=0;} + int32_t dz3,dz4; + if(rng.r250_drand()>0.5){dz3=1;dz4=-1;} + else{dz3=-1;dz4=1;} +// rng.r250_drand()>0.5 ? dz3=1 : dz3=-1; +// rng.r250_drand()>0.5 ? dz4=1 : dz4=-1; + vec1=VectorInt3( dx2, dy2, dz2+dz3); + vec2=VectorInt3(-dx2, -dy2, -dz2+dz4); + } + // set positions of monomers and two which guarantee that ring is threaded + std::vector PotentialPositions(6,StartPosition); + PotentialPositions[0]+=VectorInt3( dx1, dy1, dz1); + PotentialPositions[2]+=VectorInt3(-dx1,-dy1,-dz1); + PotentialPositions[4]+=VectorInt3( dx2, dy2, dz2);//position to check, not to use for a monomer + PotentialPositions[5]+=VectorInt3(-dx2,-dy2,-dz2);//position to check, not to use for a monomer + PotentialPositions[1]+=vec1; + PotentialPositions[3]+=vec2; + + // check if positions are occupied + bool PositionsFit(true); + for(uint32_t i=0; i addmove; + addmove.init(ingredients); + addmove.setPosition(PotentialPositions[i]); + if(addmove.check(ingredients)==false){PositionsFit=false;} + } + // add ring to system + if (PositionsFit) + { + bool AddRing(true); + for(uint32_t i=0; i3 && AddRing ) + { + for (uint32_t j=0;j +void UpdaterAbstractCreateAllBonds::moveSystem(int32_t nsteps){ + MoveLocalSc move; + for(int32_t n=0;n +void UpdaterAbstractCreateAllBonds::linearizeSystem(){ + //call ingredients copy constructor + IngredientsType newIngredients(ingredients); + + //delete all the informations in molecules + newIngredients.modifyMolecules().clear(); + + std::vector < MonomerGroup > LinearMonomerGroupsVector; + + fill_connected_groups( ingredients.getMolecules(), LinearMonomerGroupsVector, MonomerGroup(ingredients.getMolecules()), alwaysTrue() ); + + for(size_t groups=0; groups < LinearMonomerGroupsVector.size(); ++groups){ + if(groups==0) + newIngredients.modifyMolecules() = LinearMonomerGroupsVector[groups].copyGroup(); + else + newIngredients.modifyMolecules() += LinearMonomerGroupsVector[groups].copyGroup(); + } + + ingredients=newIngredients; + +} + +/******************************************************************************/ +/** + * @brief function to get a random bondvector of length 2 which is part of the bondvectorset + * @param nsteps number of MCS to move + */ +template +VectorInt3 UpdaterAbstractCreateAllBonds::randomBondvector(){ + if ( lookupFilled == false ){ + + for (auto it=ingredients.getBondset().begin(); it!= ingredients.getBondset().end();it++){ + auto bondvector(it->second); + if (ingredients.getBondset().isValidStrongCheck( bondvector ) ) + bondvectorSet.push_back(bondvector); + } + lookupFilled=true; + } + //get a random direction for the bondvector of length 2 + return bondvectorSet[ rng.r250_rand32() % bondvectorSet.size()] ; +} +#endif /* LEMONADE_UPDATER_ABSTRACT_CREATE_H */ diff --git a/include/LeMonADE_PM/updater/UpdaterAddStars.h b/include/LeMonADE_PM/updater/UpdaterAddStars.h index 4ee111f..d0c8ace 100644 --- a/include/LeMonADE_PM/updater/UpdaterAddStars.h +++ b/include/LeMonADE_PM/updater/UpdaterAddStars.h @@ -51,14 +51,16 @@ along with LeMonADE. If not, see . * @param type2_ attribute tag of "odd" monomers **/ -#include +// #include #include #include +#include + template -class UpdaterAddStars: public UpdaterAbstractCreate +class UpdaterAddStars: public UpdaterAbstractCreateAllBonds { - typedef UpdaterAbstractCreate BaseClass; + typedef UpdaterAbstractCreateAllBonds BaseClass; public: UpdaterAddStars(IngredientsType& ingredients_, uint32_t NStar_, @@ -68,9 +70,6 @@ class UpdaterAddStars: public UpdaterAbstractCreate virtual bool execute(); virtual void cleanup(); - //! getter function for write compressed solvent bool - const bool getIsSolvent() const {return IsSolvent;} - //! getter function for number of stars const int32_t getNStar() const {return NStar;} @@ -124,7 +123,7 @@ UpdaterAddStars::UpdaterAddStars( uint32_t NBranchPerStar_ ): BaseClass(ingredients_), NStar(NStar_), NMonoPerBranch(NMonoPerBranch_), NBranchPerStar(NBranchPerStar_), - density(0.0), wasExecuted(false), + density(0.0), wasExecuted(false) {} /** @@ -153,18 +152,18 @@ template < class IngredientsType > bool UpdaterAddStars::execute(){ if(wasExecuted) return true; std::cout << "execute UpdaterAddStars" << std::endl; - //loop over stars and star monomers and build it up - uint32_t gen; - uint32_t index_center; - for(uint32_t i=0;i<(NStar);i++){ + for(uint32_t i=0;i. #include #include #include -#include +#include #include #include #include -#include + #include #include +#include #include @@ -52,7 +53,7 @@ along with LeMonADE. If not, see . #include #include #include -#include +#include #include #include #include @@ -62,7 +63,7 @@ int main(int argc, char* argv[]){ try{ /////////////////////////////////////////////////////////////////////////////// ///parse options/// - std::string inputBFM("init.bfm"); + // std::string inputBFM("init.bfm"); std::string outputDataPos("CrosslinkPosition.dat"); std::string outputDataDist("ChainExtensionDistribution.dat"); std::string feCurve(""); @@ -70,18 +71,25 @@ int main(int argc, char* argv[]){ double threshold(0.5); double factor(0.995); double stretching_factor(1.0); - bool gauss(false); - + uint32_t gauss(0); + + uint32_t nSegments(16); + uint32_t functionality(4); + uint32_t nRings(0); + bool showHelp = false; auto parser - = clara::detail::Opt( inputBFM, "inputBFM (=inconfig.bfm)" ) ["-i"]["--input" ] ("(required)Input filename of the bfm file" ).required() - | clara::detail::Opt( outputDataPos, "outputDataPos (=CrosslinkPosition.dat)" ) ["-o"]["--outputPos" ] ("(optional) Output filename of the crosslink ID and the equilibrium Position.").optional() + // = clara::detail::Opt( inputBFM, "inputBFM (=inconfig.bfm)" ) ["-i"]["--input" ] ("(required)Input filename of the bfm file" ).required() + = clara::detail::Opt( outputDataPos, "outputDataPos (=CrosslinkPosition.dat)" ) ["-o"]["--outputPos" ] ("(optional) Output filename of the crosslink ID and the equilibrium Position.").optional() | clara::detail::Opt( outputDataDist, "outputDataDist (=ChainExtensionDistribution.dat)") ["-c"]["--outputDist" ] ("(optional) Output filename of the chain extension distribution." ).optional() | clara::detail::Opt( threshold, "threshold" ) ["-t"]["--threshold" ] ("(optional) Threshold of the average shift. Default 0.5 ." ).optional() | clara::detail::Opt( stretching_factor, "stretching_factor (=1)" ) ["-l"]["--stretching_factor"] ("(optional) Stretching factor for uniaxial deformation. Default 1.0 ." ).optional() | clara::detail::Opt( feCurve, "feCurve (="")" ) ["-f"]["--feCurve" ] ("(optional) Force-Extension curve. Default \"\"." ).required() | clara::detail::Opt( relaxationParameter, "relaxationParameter (=10)" ) ["-r"]["--relax" ] ("(optional) Relaxation parameter. Default 10.0 ." ).optional() | clara::detail::Opt( gauss, "gauss" ) ["-g"]["--gauss" ] ("(optional) Deforma with a Gaussian deformation behaviour. Default 1.0 ." ).optional() + | clara::detail::Opt( nSegments, "nSegments" ) ["-n"]["--nSegments" ] ("(optional) Number of segments for the strand." ).optional() + | clara::detail::Opt( functionality, "nStrands" ) ["-s"]["--nStrands" ] ("(optional) Functionality." ).optional() + | clara::detail::Opt( nRings, "nRings" ) ["-m"]["--nRings" ] ("(optional) number of rings." ).optional() | clara::Help( showHelp ); auto result = parser.parse( clara::Args( argc, argv ) ); @@ -90,17 +98,20 @@ int main(int argc, char* argv[]){ std::cerr << "Error in command line: " << result.errorMessage() << std::endl; exit(1); }else if(showHelp == true){ - std::cout << "Simulator to connect linear chains with single monomers of certain functionality"<< std::endl; + // std::cout << "Simulator to connect linear chains with single monomers of certain functionality"<< std::endl; parser.writeToStream(std::cout); exit(0); }else{ std::cout << "outputData : " << outputDataPos << std::endl; std::cout << "outputDataDist : " << outputDataDist << std::endl; - std::cout << "inputBFM : " << inputBFM << std::endl; + // std::cout << "inputBFM : " << inputBFM << std::endl; std::cout << "threshold : " << threshold << std::endl; std::cout << "feCurve : " << feCurve << std::endl; std::cout << "gauss : " << gauss << std::endl; std::cout << "stretching_factor : " << stretching_factor << std::endl; + std::cout << "nSegments : " << nSegments << std::endl; + std::cout << "functionality : " << functionality << std::endl; + std::cout << "nRings : " << nRings << std::endl; } RandomNumberGenerators rng; // rng.seedDefaultValuesAll(); @@ -109,22 +120,28 @@ int main(int argc, char* argv[]){ ///end options parsing /////////////////////////////////////////////////////////////////////////////// //Read in th last Config - typedef LOKI_TYPELIST_4(FeatureMoleculesIOUnsaveCheck, FeatureLabel, FeatureReactiveBonds,FeatureFixedMonomers) Features; + typedef LOKI_TYPELIST_1(FeatureMoleculesIO) Features; typedef ConfigureSystem Config; typedef Ingredients Ing; Ing myIngredients; - + myIngredients.setBoxX(256); + myIngredients.setBoxY(256); + myIngredients.setBoxZ(256); + myIngredients.setPeriodicX(1); + myIngredients.setPeriodicY(1); + myIngredients.setPeriodicZ(1); + myIngredients.modifyBondset().addBFMclassicBondset(); + myIngredients.synchronize(); TaskManager taskmanager; - - taskmanager.addUpdater( new UpdaterAddStars(inputBFM,myIngredients, UpdaterReadBfmFile::READ_LAST_CONFIG_SAVE),0); - - //initialize and run + taskmanager.addUpdater( new UpdaterAddStars(myIngredients,1, nSegments+1 , functionality ),0); + taskmanager.addAnalyzer(new AnalyzerWriteBfmFile("config.bfm", myIngredients, AnalyzerWriteBfmFile::APPEND) ); taskmanager.initialize(); taskmanager.run(1); taskmanager.cleanup(); + std::cout << "Read in conformation and go on to bring it into equilibrium forces..." < Config2; typedef Ingredients Ing2; Ing2 myIngredients2; @@ -137,42 +154,54 @@ int main(int argc, char* argv[]){ myIngredients2.setPeriodicZ(myIngredients.isPeriodicZ()); myIngredients2.modifyMolecules().resize(myIngredients.getMolecules().size()); myIngredients2.modifyMolecules().setAge(myIngredients.getMolecules().getAge()); - - myIngredients2.setNumTendomers (myIngredients.getNumTendomers()); - myIngredients2.setNumCrossLinkers (myIngredients.getNumCrossLinkers()); - myIngredients2.setNumMonomersPerChain (myIngredients.getNumMonomersPerChain()); - myIngredients2.setNumLabelsPerTendomerArm(myIngredients.getNumLabelsPerTendomerArm()); + + myIngredients2.setNumOfChains (functionality*1); + myIngredients2.setNumOfCrosslinks (functionality+1); + myIngredients2.setNumOfMonomersPerChain (nSegments); + myIngredients2.setNumOfMonomersPerCrosslink(1); + myIngredients2.setFunctionality (functionality); + for(size_t i = 0; i< myIngredients.getMolecules().size();i++){ myIngredients2.modifyMolecules()[i].modifyVector3D()=myIngredients.getMolecules()[i].getVector3D(); - myIngredients2.modifyMolecules()[i].setReactive(myIngredients.getMolecules()[i].isReactive()); - myIngredients2.modifyMolecules()[i].setNumMaxLinks(myIngredients.getMolecules()[i].getNumMaxLinks()); for (size_t j = 0 ; j < myIngredients.getMolecules().getNumLinks(i);j++){ uint32_t neighbor(myIngredients.getMolecules().getNeighborIdx(i,j)); if( ! myIngredients2.getMolecules().areConnected(i,neighbor) ) myIngredients2.modifyMolecules().connect(i,neighbor); } } + for (auto i=0; i < functionality; i ++) { + uint32_t ID(1 + (i+1)*(nSegments+1) -1); + // if(gauss == 1 ){ + // rng.r250_drand() + + // } + std::cout << "Fixed monomers= "<< ID <(myIngredients2, stretching_factor),0 ); + // taskmanager2.addUpdater( new UpdaterAffineDeformation(myIngredients2, stretching_factor),0 ); //read bonds and positions stepwise auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; updater->setFilename(feCurve); updater->setRelaxationParameter(relaxationParameter); auto updater2 = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; if ( gauss == 0 ){ - std::cout << "TendomerNetworkForceEquilibrium: add UpdaterForceBalancedPosition(myIngredients2, threshold) \n"; + std::cout << "IdealReferenceForceEquilibrium: add UpdaterForceBalancedPosition(myIngredients2, threshold) \n"; taskmanager2.addUpdater( updater ); - }else { - std::cout << "TendomerNetworkForceEquilibrium: add UpdaterForceBalancedPosition(myIngredients2, threshold) \n"; + }else if( gauss == 1 ){ + std::cout << "IdealReferenceForceEquilibrium: add UpdaterForceBalancedPosition(myIngredients2, threshold) \n"; taskmanager2.addUpdater( updater2 ); } + taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,outputDataPos, outputDataDist)); //initialize and run taskmanager2.initialize(); taskmanager2.run(); + if(gauss > 1) + taskmanager2.run(1); taskmanager2.cleanup(); } From 7f4afc99ed0d46306e4a9ea77375f89d21967cc6 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Sat, 30 Oct 2021 16:57:56 +0200 Subject: [PATCH 45/70] change the FeatureCrosslinkConnectionsLookUpIdealReference to use the getMovableFlag to determine the neighbors --- ...CrosslinkConnectionsLookUpIdealReference.h | 136 ++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 include/LeMonADE_PM/feature/FeatureCrosslinkConnectionsLookUpIdealReference.h diff --git a/include/LeMonADE_PM/feature/FeatureCrosslinkConnectionsLookUpIdealReference.h b/include/LeMonADE_PM/feature/FeatureCrosslinkConnectionsLookUpIdealReference.h new file mode 100644 index 0000000..063aaba --- /dev/null +++ b/include/LeMonADE_PM/feature/FeatureCrosslinkConnectionsLookUpIdealReference.h @@ -0,0 +1,136 @@ +/*-------------------------------------------------------------------------------- + ooo L attice-based | + o\.|./o e xtensible | LeMonADE: An Open Source Implementation of the + o\.\|/./o Mon te-Carlo | Bond-Fluctuation-Model for Polymers +oo---0---oo A lgorithm and | + o/./|\.\o D evelopment | Copyright (C) 2013-2015 by + o/.|.\o E nvironment | LeMonADE Principal Developers (see AUTHORS) + ooo | +---------------------------------------------------------------------------------- + +This file is part of LeMonADE. + +LeMonADE 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. + +LeMonADE 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 LeMonADE. If not, see . + +--------------------------------------------------------------------------------*/ + + +#ifndef LENONADE_PM_FEATURE_FEATURECROSSLINKCONNECTIONLOOKUPIDEALREFERENCE_H +#define LENONADE_PM_FEATURE_FEATURECROSSLINKCONNECTIONLOOKUPIDEALREFERENCE_H + +#include +#include +#include +#include +#include +#include + + +/*****************************************************************************/ +/** + * @file + * @date 2021/04/01 + * @author Toni + * + * @class FeatureCrosslinkConnectionsLookUpIdealReference + * @brief Creates a lookup for crosslink IDs and their neighbors + * @details For calculating the equilibrium position of crosslinks in a + * a phantom network, one needs to know the crosslink neighbors and the number + * of segments between them. + * + **/ +/*****************************************************************************/ +/////////////////////////////////////////////////////////////////////////////// +//DEFINITION OF THE CLASS TEMPLATE /////// +//Implementation of the members below /////// +/////////////////////////////////////////////////////////////////////////////// + +class FeatureCrosslinkConnectionsLookUpIdealReference : public Feature { + +public: + //! This Feature requires a monomer_extensions. + typedef LOKI_TYPELIST_1(MonomerReactivity) monomer_extensions; + + //! check bas connect move - always true + template + bool checkMove(const IngredientsType& ingredients, const MoveBase& move) const { return true;}; + + //! synchronize lookup table + template + void synchronize(IngredientsType& ingredients) { + fillTables(ingredients); + }; + //! set the jump vector + void setCrossLinkNeighborJump(uint32_t CrossLinkID, uint32_t idx, VectorDouble3 vec) { + if ( idx > CrossLinkNeighbors.at(CrossLinkID).size() ){ + std::stringstream errormessage; + errormessage << "FeatureCrosslinkConnectionsLookUpTendomers::setCrossLinkNeighborJump neighbor idx " << idx <<" is to high."; + throw std::runtime_error(errormessage.str()); + } + CrossLinkNeighbors.at(CrossLinkID)[idx].jump=vec; + } + //!getter function for the neighboring crosslinks + std::vector getCrossLinkNeighborIDs(uint32_t CrossLinkID) const{ + #ifdef DEBUG + if (CrossLinkNeighbors.find(CrossLinkID) == CrossLinkNeighbors.end()){ + std::stringstream errormessage; + errormessage << "FeatureCrosslinkConnectionsLookUpIdealReference::getCrossLinkNeighborIDs Cross Link ID " << CrossLinkID <<" does not exist."; + throw std::runtime_error(errormessage.str()); + } + #endif + return CrossLinkNeighbors.at(CrossLinkID); + }; + + //!get the ID of crosslinks (determined by nConnections>3 and connected to another crosslink) + const std::vector& getCrosslinkIDs() const {return crosslinkIDs;} + +private: + //! convinience function to fill all tables + template + void fillTables(IngredientsType& ingredients); + //!key - CrossLink ID; value - neighboring cross link and the number of segments to them + std::map > CrossLinkNeighbors; + //!ID for crosslinks + std::vector crosslinkIDs; +}; +/** + *@details Create look up table + **/ +template +void FeatureCrosslinkConnectionsLookUpIdealReference::fillTables(IngredientsType& ingredients){ + + const typename IngredientsType::molecules_type& molecules=ingredients.getMolecules(); + std::cout << "FeatureCrosslinkConnectionsLookUpIdealReference::fillTables" < NeighborIDs; + VectorDouble3 jumpVector(0.,0.,0.); + uint32_t nSegments(ingredients.getNumOfMonomersPerChain()); + for (auto i=0; i < ingredients.getMolecules().size(); i++){ + if (ingredients.getMolecules()[i].getMovableTag() == false) + NeighborIDs.push_back( neighborX(i, i%(nSegments+1), jumpVector) ); + + } + + // for( auto i=0; i NeighborIDs1; + // // NeighborIDs1 + // } + CrossLinkNeighbors[0]=NeighborIDs; + + std::cout << "FeatureCrosslinkConnectionsLookUpIdealReference::fillTables.done" < Date: Sat, 30 Oct 2021 16:58:22 +0200 Subject: [PATCH 46/70] add functionality to set the jump vector in FeatureCrosslinkConnectionsLookUp --- .../feature/FeatureCrosslinkConnectionsLookUp.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/include/LeMonADE_PM/feature/FeatureCrosslinkConnectionsLookUp.h b/include/LeMonADE_PM/feature/FeatureCrosslinkConnectionsLookUp.h index 7c50e2c..2b2b3ff 100644 --- a/include/LeMonADE_PM/feature/FeatureCrosslinkConnectionsLookUp.h +++ b/include/LeMonADE_PM/feature/FeatureCrosslinkConnectionsLookUp.h @@ -71,7 +71,15 @@ class FeatureCrosslinkConnectionsLookUp : public Feature { void synchronize(IngredientsType& ingredients) { fillTables(ingredients); }; - + //! set the jump vector + void setCrossLinkNeighborJump(uint32_t CrossLinkID, uint32_t idx, VectorDouble3 vec) { + if ( idx > CrossLinkNeighbors.at(CrossLinkID).size() ){ + std::stringstream errormessage; + errormessage << "FeatureCrosslinkConnectionsLookUpTendomers::setCrossLinkNeighborJump neighbor idx " << idx <<" is to high."; + throw std::runtime_error(errormessage.str()); + } + CrossLinkNeighbors.at(CrossLinkID)[idx].jump=vec; + } //!getter function for the neighboring crosslinks std::vector getCrossLinkNeighborIDs(uint32_t CrossLinkID) const{ #ifdef DEBUG From 2382ace42d5bb2a1bf60c3c03567158d2f1b1da4 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Fri, 5 Nov 2021 11:32:31 +0100 Subject: [PATCH 47/70] add the possibility to analyze the chain extension wihtout force equilibration (for e.g. doing a comparison before and after...) --- projects/TendomerNetworkForceEquilibrium.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/TendomerNetworkForceEquilibrium.cpp b/projects/TendomerNetworkForceEquilibrium.cpp index dd4c413..c17f819 100644 --- a/projects/TendomerNetworkForceEquilibrium.cpp +++ b/projects/TendomerNetworkForceEquilibrium.cpp @@ -163,7 +163,7 @@ int main(int argc, char* argv[]){ if ( gauss == 0 ){ std::cout << "TendomerNetworkForceEquilibrium: add UpdaterForceBalancedPosition(myIngredients2, threshold) \n"; taskmanager2.addUpdater( updater ); - }else { + }else if {gauss == 1 }{ std::cout << "TendomerNetworkForceEquilibrium: add UpdaterForceBalancedPosition(myIngredients2, threshold) \n"; taskmanager2.addUpdater( updater2 ); } From caaec19e2984a5b8efae4cc2f0d1db2b14ed5271 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Fri, 5 Nov 2021 11:34:22 +0100 Subject: [PATCH 48/70] add the possibility to decrease the relaxation factor. This is needed if the positions osscilate! --- .../updater/UpdaterForceBalancedPosition.h | 12 ++++++++++-- .../updater/moves/MoveNonLinearForceEquilibrium.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h b/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h index 6cb956e..d890b36 100644 --- a/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h +++ b/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h @@ -40,8 +40,8 @@ class UpdaterForceBalancedPosition:public AbstractUpdater { public: //! constructor for UpdaterForceBalancedPosition - UpdaterForceBalancedPosition(IngredientsType& ing_, double threshold_ ): - ing(ing_),threshold(threshold_){}; + UpdaterForceBalancedPosition(IngredientsType& ing_, double threshold_ , double decreaseFactor_=1.0): + ing(ing_),threshold(threshold_),decreaseFactor(decreaseFactor_){}; virtual void initialize(){}; bool execute(); @@ -61,6 +61,9 @@ class UpdaterForceBalancedPosition:public AbstractUpdater //! random number generator RandomNumberGenerators rng; + + //! + double decreaseFactor; }; template @@ -87,6 +90,11 @@ bool UpdaterForceBalancedPosition::execute(){ ing.modifyMolecules().setAge(ing.getMolecules().getAge()+1); if (ing.getMolecules().getAge() %1000 == 0 ){ std::cout << "MCS: " << ing.getMolecules().getAge() << " and average shift: " << avShift << std::endl; + + } + if (ing.getMolecules().getAge() %100 == 0 ){ + setRelaxationParameter(move.getRelaxationParameter()*decreaseFactor); + threshold*=decreaseFactor; } } std::cout << "Finish equilibration with average shift per cross link < " << avShift << " after " << ing.getMolecules().getAge()-StartMCS <getIndex()<<" "<< Neighbors[i].ID<< " " <(number_of_neighbors) )); } From b6ccc60d726cd17d03061850265fa4d96693690f Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Fri, 5 Nov 2021 11:35:28 +0100 Subject: [PATCH 49/70] add the possibility to simulate tendomers with their correct distribution of segments in the elastic chains --- projects/IdealReferenceForceEquilibrium.cpp | 37 ++++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/projects/IdealReferenceForceEquilibrium.cpp b/projects/IdealReferenceForceEquilibrium.cpp index 1c79b51..7ef6fa6 100644 --- a/projects/IdealReferenceForceEquilibrium.cpp +++ b/projects/IdealReferenceForceEquilibrium.cpp @@ -59,6 +59,10 @@ along with LeMonADE. If not, see . #include +double probabilityFunction(double n, double p) { + return (p*p*n*pow(1-p,n-1.)); + } + int main(int argc, char* argv[]){ try{ /////////////////////////////////////////////////////////////////////////////// @@ -170,12 +174,35 @@ int main(int argc, char* argv[]){ myIngredients2.modifyMolecules().connect(i,neighbor); } } + uint32_t steps(50000); + //cummulative distribution function + std::vector CPF((nSegments- nRings)*2,0); + //distribution function + std::vector PF((nSegments- nRings)*2,0); + + double p( (nRings+2. )/( nSegments- nRings - 1. ) ); + std::cout << "p=" << p << " n0="<< 1./p<< std::endl; + for (auto i = 0; i < (nSegments- nRings)*2; i++ ){ + PF[i]=probabilityFunction(i,p); + if( i==0 ) + CPF[i]=PF[i]; + else + CPF[i]=CPF[i-1]+PF[i]; + } + + std::vector invCPF(steps-1,0); + for (auto i =1 ; i < steps-1; i++) { + uint32_t n=0 ; + auto prob=static_cast (i) / static_cast(steps ); + while ( prob > CPF [ n ] ){ n++;} + invCPF[i]=(n-1) + static_cast(round( (n-(n-1)) *( prob- CPF[n-1] )/(CPF[n]-CPF[n-1]) )); + // std::cout << "invCPF: " << prob << " " << invCPF[i] <<" "<< n-1 <<" "<(myIngredients2, threshold) \n"; taskmanager2.addUpdater( updater ); - }else if {gauss == 1 }{ + }else if (gauss == 1 ){ std::cout << "TendomerNetworkForceEquilibrium: add UpdaterForceBalancedPosition(myIngredients2, threshold) \n"; taskmanager2.addUpdater( updater2 ); } From 945480c384b08f0808773bc50e4c99e0bd9b0703 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Fri, 12 Nov 2021 17:22:17 +0100 Subject: [PATCH 51/70] adapt the tendomer ideal system to the distribution of the elastic segment number --- projects/IdealReferenceForceEquilibrium.cpp | 55 +++++++++++++-------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/projects/IdealReferenceForceEquilibrium.cpp b/projects/IdealReferenceForceEquilibrium.cpp index 7ef6fa6..e69e80e 100644 --- a/projects/IdealReferenceForceEquilibrium.cpp +++ b/projects/IdealReferenceForceEquilibrium.cpp @@ -59,10 +59,9 @@ along with LeMonADE. If not, see . #include -double probabilityFunction(double n, double p) { - return (p*p*n*pow(1-p,n-1.)); - } - +double prob_q(double n, double N, double m) { + return (m+1.)/(N-n-1.); + } int main(int argc, char* argv[]){ try{ /////////////////////////////////////////////////////////////////////////////// @@ -137,7 +136,7 @@ int main(int argc, char* argv[]){ myIngredients.modifyBondset().addBFMclassicBondset(); myIngredients.synchronize(); TaskManager taskmanager; - taskmanager.addUpdater( new UpdaterAddStars(myIngredients,1, nSegments+1 , functionality ),0); + taskmanager.addUpdater( new UpdaterAddStars(myIngredients,1, 2*nSegments+1 , functionality ),0); taskmanager.addAnalyzer(new AnalyzerWriteBfmFile("config.bfm", myIngredients, AnalyzerWriteBfmFile::APPEND) ); taskmanager.initialize(); taskmanager.run(1); @@ -161,7 +160,7 @@ int main(int argc, char* argv[]){ myIngredients2.setNumOfChains (functionality*1); myIngredients2.setNumOfCrosslinks (functionality+1); - myIngredients2.setNumOfMonomersPerChain (nSegments); + myIngredients2.setNumOfMonomersPerChain (2*nSegments); myIngredients2.setNumOfMonomersPerCrosslink(1); myIngredients2.setFunctionality (functionality); @@ -174,22 +173,36 @@ int main(int argc, char* argv[]){ myIngredients2.modifyMolecules().connect(i,neighbor); } } - uint32_t steps(50000); - //cummulative distribution function - std::vector CPF((nSegments- nRings)*2,0); - //distribution function - std::vector PF((nSegments- nRings)*2,0); - - double p( (nRings+2. )/( nSegments- nRings - 1. ) ); - std::cout << "p=" << p << " n0="<< 1./p<< std::endl; - for (auto i = 0; i < (nSegments- nRings)*2; i++ ){ - PF[i]=probabilityFunction(i,p); - if( i==0 ) - CPF[i]=PF[i]; - else - CPF[i]=CPF[i-1]+PF[i]; + + //probability distribution function + std::cout << "Calculate PDF" << std::endl; + std::vector PF((nSegments-nRings),0); + double sum(0.); + for (auto i = 1; i < (nSegments- nRings); i++ ){ + PF[i]=prob_q(i,nSegments,nRings)*(1.-sum); + // std::cout << "probabilityDisti "< convPF((nSegments- nRings)*2,0); + for (auto i=0; i < 2*(nSegments-nRings);i++){ + for(auto j=0; j < i ; j++){ + convPF[i]+=PF[j]*PF[i-j]; + } + // std::cout << "ConvprobabilityDisti "< CPF((nSegments- nRings)*2,0); + for (auto i=1; i < 2*(nSegments-nRings);i++){ + CPF[i]+=CPF[i-1]+convPF[i]; + } + //calculate the inverse cummulative convoluted probability distribution + std::cout << "Calculate inverse cummulative convoluted PDF" << std::endl; + uint32_t steps(50000); std::vector invCPF(steps-1,0); for (auto i =1 ; i < steps-1; i++) { uint32_t n=0 ; From b491dd6b03b0bcd356d194ee8504f7f741d8fddd Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Thu, 2 Dec 2021 11:18:49 +0100 Subject: [PATCH 52/70] Add affine deformation to the reference system --- .../FeatureCrosslinkConnectionsLookUpIdealReference.h | 2 +- projects/IdealReferenceForceEquilibrium.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/LeMonADE_PM/feature/FeatureCrosslinkConnectionsLookUpIdealReference.h b/include/LeMonADE_PM/feature/FeatureCrosslinkConnectionsLookUpIdealReference.h index 063aaba..80543a5 100644 --- a/include/LeMonADE_PM/feature/FeatureCrosslinkConnectionsLookUpIdealReference.h +++ b/include/LeMonADE_PM/feature/FeatureCrosslinkConnectionsLookUpIdealReference.h @@ -120,7 +120,7 @@ void FeatureCrosslinkConnectionsLookUpIdealReference::fillTables(IngredientsType uint32_t nSegments(ingredients.getNumOfMonomersPerChain()); for (auto i=0; i < ingredients.getMolecules().size(); i++){ if (ingredients.getMolecules()[i].getMovableTag() == false) - NeighborIDs.push_back( neighborX(i, i%(nSegments+1), jumpVector) ); + NeighborIDs.push_back( neighborX(i, ( (i-1)%((2*nSegments+1)) )+1, jumpVector) ); } diff --git a/projects/IdealReferenceForceEquilibrium.cpp b/projects/IdealReferenceForceEquilibrium.cpp index e69e80e..b3e3cbc 100644 --- a/projects/IdealReferenceForceEquilibrium.cpp +++ b/projects/IdealReferenceForceEquilibrium.cpp @@ -92,7 +92,7 @@ int main(int argc, char* argv[]){ | clara::detail::Opt( gauss, "gauss" ) ["-g"]["--gauss" ] ("(optional) Deforma with a Gaussian deformation behaviour. Default 1.0 ." ).optional() | clara::detail::Opt( nSegments, "nSegments" ) ["-n"]["--nSegments" ] ("(optional) Number of segments for the strand." ).optional() | clara::detail::Opt( functionality, "nStrands" ) ["-s"]["--nStrands" ] ("(optional) Functionality." ).optional() - | clara::detail::Opt( nRings, "nRings" ) ["-m"]["--nRings" ] ("(optional) number of rings." ).optional() + | clara::detail::Opt( nRings, "nRings" ) ["-m"]["--nRings" ] ("(optional) number of rings." ).optional() | clara::Help( showHelp ); auto result = parser.parse( clara::Args( argc, argv ) ); @@ -213,16 +213,16 @@ int main(int argc, char* argv[]){ } for (auto i=0; i < functionality; i ++) { - uint32_t ID(1 + (i+1)*(nSegments+1) -1); + uint32_t ID(1 + (i+1)*(2*nSegments+1) -1); if(gauss == 0 ) - ID = invCPF[rng.r250_rand32() % steps ] +(nSegments +1) *i+1; + ID = invCPF[rng.r250_rand32() % steps ] +(2*nSegments +1) *i+1; std::cout << "Fixed monomers= "<< ID <(myIngredients2, stretching_factor),0 ); + taskmanager2.addUpdater( new UpdaterAffineDeformation(myIngredients2, stretching_factor),0 ); //read bonds and positions stepwise auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold,0.95) ; updater->setFilename(feCurve); From 66ffaac032cad2a44d1f5be18440150013e95faf Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Thu, 2 Dec 2021 11:19:56 +0100 Subject: [PATCH 53/70] add the second referemce system: two connected stars with fixes ends following the TM statistics for the segments --- ...onnectionsLookUpIdealDoubleStarReference.h | 192 ++++++++++++ .../updater/UpdaterAddTMDoubleStars.h | 278 ++++++++++++++++++ projects/CMakeLists.txt | 3 + projects/IdealReference2ForceEquilibrium.cpp | 202 +++++++++++++ 4 files changed, 675 insertions(+) create mode 100644 include/LeMonADE_PM/feature/FeatureCrosslinkConnectionsLookUpIdealDoubleStarReference.h create mode 100644 include/LeMonADE_PM/updater/UpdaterAddTMDoubleStars.h create mode 100644 projects/IdealReference2ForceEquilibrium.cpp diff --git a/include/LeMonADE_PM/feature/FeatureCrosslinkConnectionsLookUpIdealDoubleStarReference.h b/include/LeMonADE_PM/feature/FeatureCrosslinkConnectionsLookUpIdealDoubleStarReference.h new file mode 100644 index 0000000..218c82e --- /dev/null +++ b/include/LeMonADE_PM/feature/FeatureCrosslinkConnectionsLookUpIdealDoubleStarReference.h @@ -0,0 +1,192 @@ +/*-------------------------------------------------------------------------------- + ooo L attice-based | + o\.|./o e xtensible | LeMonADE: An Open Source Implementation of the + o\.\|/./o Mon te-Carlo | Bond-Fluctuation-Model for Polymers +oo---0---oo A lgorithm and | + o/./|\.\o D evelopment | Copyright (C) 2013-2015 by + o/.|.\o E nvironment | LeMonADE Principal Developers (see AUTHORS) + ooo | +---------------------------------------------------------------------------------- + +This file is part of LeMonADE. + +LeMonADE 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. + +LeMonADE 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 LeMonADE. If not, see . + +--------------------------------------------------------------------------------*/ + + +#ifndef LENONADE_PM_FEATURE_FEATURECROSSLINKCONNECTIONLOOKUPIDEALREFERENCE_H +#define LENONADE_PM_FEATURE_FEATURECROSSLINKCONNECTIONLOOKUPIDEALREFERENCE_H + +#include +#include +#include +#include +#include +#include + + +/*****************************************************************************/ +/** + * @file + * @date 2021/04/01 + * @author Toni + * + * @class FeatureCrosslinkConnectionsLookUpIdealDoubleStarReference + * @brief Creates a lookup for crosslink IDs and their neighbors + * @details For calculating the equilibrium position of crosslinks in a + * a phantom network, one needs to know the crosslink neighbors and the number + * of segments between them. + * + **/ +/*****************************************************************************/ +/////////////////////////////////////////////////////////////////////////////// +//DEFINITION OF THE CLASS TEMPLATE /////// +//Implementation of the members below /////// +/////////////////////////////////////////////////////////////////////////////// + +class FeatureCrosslinkConnectionsLookUpIdealDoubleStarReference : public Feature { + +public: + //! This Feature requires a monomer_extensions. + typedef LOKI_TYPELIST_1(MonomerReactivity) monomer_extensions; + + //! check bas connect move - always true + template + bool checkMove(const IngredientsType& ingredients, const MoveBase& move) const { return true;}; + + //! synchronize lookup table + template + void synchronize(IngredientsType& ingredients) { + fillTables(ingredients); + }; + //! set the jump vector + void setCrossLinkNeighborJump(uint32_t CrossLinkID, uint32_t idx, VectorDouble3 vec) { + if ( idx > CrossLinkNeighbors.at(CrossLinkID).size() ){ + std::stringstream errormessage; + errormessage << "FeatureCrosslinkConnectionsLookUpTendomers::setCrossLinkNeighborJump neighbor idx " << idx <<" is to high."; + throw std::runtime_error(errormessage.str()); + } + CrossLinkNeighbors.at(CrossLinkID)[idx].jump=vec; + } + //!getter function for the neighboring crosslinks + std::vector getCrossLinkNeighborIDs(uint32_t CrossLinkID) const{ + #ifdef DEBUG + if (CrossLinkNeighbors.find(CrossLinkID) == CrossLinkNeighbors.end()){ + std::stringstream errormessage; + errormessage << "FeatureCrosslinkConnectionsLookUpIdealDoubleStarReference::getCrossLinkNeighborIDs Cross Link ID " << CrossLinkID <<" does not exist."; + throw std::runtime_error(errormessage.str()); + } + #endif + return CrossLinkNeighbors.at(CrossLinkID); + }; + + //!get the ID of crosslinks (determined by nConnections>3 and connected to another crosslink) + const std::vector& getCrosslinkIDs() const {return crosslinkIDs;} + +private: + //! convinience function to fill all tables + template + void fillTables(IngredientsType& ingredients); + //!key - CrossLink ID; value - neighboring cross link and the number of segments to them + std::map > CrossLinkNeighbors; + //!ID for crosslinks + std::vector crosslinkIDs; +}; +/** + *@details Create look up table + **/ +template +void FeatureCrosslinkConnectionsLookUpIdealDoubleStarReference::fillTables(IngredientsType& ingredients){ + + const typename IngredientsType::molecules_type& molecules=ingredients.getMolecules(); + std::cout << "FeatureCrosslinkConnectionsLookUpIdealDoubleStarReference::fillTables" < NeighborIDs; + // VectorDouble3 jumpVector(0.,0.,0.); + // uint32_t nSegments(ingredients.getNumOfMonomersPerChain()); + // for (auto i=0; i < ingredients.getMolecules().size(); i++){ + // if (ingredients.getMolecules()[i].getMovableTag() == false) + // NeighborIDs.push_back( neighborX(i, ( (i-1)%((2*nSegments+1)) )+1, jumpVector) ); + + // } + + // // for( auto i=0; i NeighborIDs1; + // // // NeighborIDs1 + // // } + // CrossLinkNeighbors[0]=NeighborIDs; + + + + for (uint32_t i = 0 ;i < molecules.size();i++){ + //find next crosslink + if( molecules.getNumLinks(i) > 2 ){ + //temporary storage for the neighboring crosslinks + std::vector NeighborIDs; + auto posX(molecules[i].getVector3D()); + for (size_t j = 0 ; j < molecules.getNumLinks(i); j++){ + uint32_t tail(i); + uint32_t head(molecules.getNeighborIdx(i,j)); + VectorDouble3 posHead(molecules[head].getVector3D()); + VectorDouble3 bond(LemonadeDistCalcs::MinImageVector( posX,posHead,ingredients)); + if(bond.getLength() > std::sqrt(10)){ + std::stringstream errormessage; + errormessage << "FeatureCrosslinkConnectionsLookUp: Wrong bond " << bond << " between " << i << " and " << head << "\n"; + throw std::runtime_error(errormessage.str()); + } + VectorDouble3 jumpVector(posHead-bond-posX); // tracks if one bond jumps across periodic images + + //direct connection of two cross links + if ( molecules.getNumLinks(head) > 2 || molecules[head].getMovableTag()==false ) { + NeighborIDs.push_back( neighborX(head, 1, jumpVector) ); + }else{ + uint32_t nSegments(1); + //cross links are connected by a chain + while( molecules.getNumLinks(head) == 2 && head != i ){ + //find next head + for (size_t k = 0 ; k < molecules.getNumLinks(head); k++){ + uint32_t NextMonomer( molecules.getNeighborIdx(head,k)); + if ( NextMonomer != tail ) { + tail=head; + head=NextMonomer; + break; + } + } + posHead=molecules[head].getVector3D(); + auto posTail=molecules[tail].getVector3D(); + bond=LemonadeDistCalcs::MinImageVector( posTail,posHead,ingredients); + jumpVector+=(posHead-bond-posTail); // tracks if one bond jumps across periodic images + nSegments++; + //a cross link has more than 2 connections + if( molecules.getNumLinks(head) > 2 || molecules[head].getMovableTag()==false ){ + NeighborIDs.push_back(neighborX(head, nSegments, jumpVector)); + break; + } + } + } + } + CrossLinkNeighbors[i]=NeighborIDs; + // if(NeighborIDs.size()>0) + crosslinkIDs.push_back(i); + } + } + + + std::cout << "FeatureCrosslinkConnectionsLookUpIdealDoubleStarReference::fillTables.done" <. + +--------------------------------------------------------------------------------*/ + +#ifndef LEMONADE_UPDATER_SETUP_TMDOUBLESTARSAB +#define LEMONADE_UPDATER_SETUP_TMDOUBLESTARSAB +/** + * @file + * + * @class UpdaterAddTMDoubleStars + * + * @brief Updater to create a solution of monodisperse branched stars. + * + * @details This is a simple implementation of a system setup starting from an empty ingredients + * or a system with some monomers inside. This updater requires FeatureAttributes. + * Two tags are added to the monomers in alternating manner, usually needed for GPU computing. // not realized in this first attempt + * // RS, 05 Nov 2019, but presumably 29 July 2020 + * + * @tparam IngredientsType + * + * @param ingredients_ The system, holding either an empty simulation box for system setup + * or a prefilled ingredients where the stars shall be added + * @param NStar_ number of stars that are added to ingredients + * @param NMonoPerStar_ number of monomers in each star + * @param NMonoPerBranch_ number of monomers in each branch (excluding central monomer) + * @param NBranchPerStar_ number of branches in each star + * @param type1_ attribute tag of "even" monomers + * @param type2_ attribute tag of "odd" monomers + **/ + +// #include +#include +#include + +#include + +template +class UpdaterAddTMDoubleStars: public UpdaterAbstractCreateAllBonds +{ + typedef UpdaterAbstractCreateAllBonds BaseClass; + +public: + UpdaterAddTMDoubleStars(IngredientsType& ingredients_, uint32_t NStar_, + uint32_t NMonoPerBranch_, uint32_t nRings_, uint32_t NBranchPerStar_); + + virtual void initialize(); + virtual bool execute(); + virtual void cleanup(); + + //! getter function for number of stars + const int32_t getNStar() const {return NStar;} + + //! getter function for number of monomers in branch + const int32_t getNMonoPerBranch() const {return NMonoPerBranch;} + + //! getter function for number of branches in stars + const int32_t getNBranchPerStar() const {return NBranchPerStar;} + + //! getter function for calculated density + const double getDensity() const {return density;} + +private: + // provide access to functions of UpdaterAbstractCreate used in this updater + using BaseClass::ingredients; + using BaseClass::addMonomerToParent; + using BaseClass::addSingleMonomer; + using BaseClass::linearizeSystem; + double prob_q(double n, double N, double m) { + return (m+1.)/(N-n-1.); + } + //! number of rings + uint32_t nRings; + //! number of stars in the box + uint32_t NStar; + + //! number of monomers in a branch + uint32_t NMonoPerBranch; + + //! number of branches in a star + uint32_t NBranchPerStar; + + //! lattice occupation density + double density; + + //! bool for execution + bool wasExecuted; + + // adds a chain of with nMonomers monomers to the parentID + void createChain(uint parentID, uint32_t nMonomers); + // add a chain to the system at a random positions + void createChain(uint32_t nMonomers); + + //! + const uint32_t steps; + //! + std::vector invCPF; + // random number generator (globally seeded) + RandomNumberGenerators rng; +}; + +/** +* @brief Constructor handling the new systems paramters +* +* @param ingredients_ a reference to the IngredientsType - mainly the system +* @param NStar_ number of double stars to be added in the system instead of solvent +* @param NBranchPerStar_ number of branches in each star +* @param NMonoPerBranch_ number of monomers in each branch (excluding central monomer) +*/ + + +template < class IngredientsType > +UpdaterAddTMDoubleStars::UpdaterAddTMDoubleStars( + IngredientsType& ingredients_, + uint32_t NStar_, + uint32_t NMonoPerBranch_, + uint32_t nRings_, + uint32_t NBranchPerStar_ + ): + BaseClass(ingredients_), NStar(NStar_), NMonoPerBranch(NMonoPerBranch_), nRings(nRings_), NBranchPerStar(NBranchPerStar_), + density(0.0), wasExecuted(false),steps(50000) + { + invCPF.resize(steps-1,0); + } + +/** +* @brief initialise function, calculate the target density to compare with at the end. +* +* @tparam IngredientsType Features used in the system. See Ingredients. +*/ +template < class IngredientsType > +void UpdaterAddTMDoubleStars::initialize(){ + std::cout << "initialize UpdaterAddTMDoubleStars" << std::endl; + + + //probability distribution function + std::cout << "Calculate PDF" << std::endl; + std::vector PF((NMonoPerBranch-nRings),0); + double sum(0.); + for (auto i = 1; i < (NMonoPerBranch- nRings); i++ ){ + PF[i]=prob_q(i,NMonoPerBranch,nRings)*(1.-sum); + // std::cout << "probabilityDisti "< convPF((NMonoPerBranch- nRings)*2,0); + for (auto i=0; i < 2*(NMonoPerBranch-nRings);i++){ + for(auto j=0; j < i ; j++){ + convPF[i]+=PF[j]*PF[i-j]; + } + // std::cout << "ConvprobabilityDisti "< CPF((NMonoPerBranch- nRings)*2,0); + for (auto i=1; i < 2*(NMonoPerBranch-nRings);i++){ + CPF[i]+=CPF[i-1]+convPF[i]; + } + //calculate the inverse cummulative convoluted probability distribution + std::cout << "Calculate inverse cummulative convoluted PDF" << std::endl; + for (auto i =1 ; i < steps-1; i++) { + uint32_t n=0 ; + auto prob=static_cast (i) / static_cast(steps ); + while ( prob > CPF [ n ] ){ n++;} + invCPF[i]=(n-1) + static_cast(round( (n-(n-1)) *( prob- CPF[n-1] )/(CPF[n]-CPF[n-1]) )); + // std::cout << "invCPF: " << prob << " " << invCPF[i] <<" "<< n-1 <<" "< +void UpdaterAddTMDoubleStars::createChain(uint32_t parentID, uint32_t nMonomers){ + auto ID(parentID); + for (auto i=0; i< nMonomers ; i++){ + addMonomerToParent(parentID,1); + parentID=(ingredients.getMolecules().size()-1); + } +} + +template < class IngredientsType > +void UpdaterAddTMDoubleStars::createChain(uint32_t nMonomers){ + addSingleMonomer(1); + createChain(ingredients.getMolecules().size()-1,nMonomers-1); +} +/** +* @brief Execution of the system creation +* +* @tparam IngredientsType Features used in the system. See Ingredients. +*/ +template < class IngredientsType > +bool UpdaterAddTMDoubleStars::execute(){ + if(wasExecuted) return true; + std::cout << "execute UpdaterAddTMDoubleStars" << std::endl; + //initial number of monomer in the system + auto nMonomers(ingredients.getMolecules().size()); + //keeps track on the monomers which are added during the procedure + auto nAddedMonomers(0); + for(uint32_t i=0;i0 ) + start=(ingredients.getMolecules().size()-1); + std::cout << "Start: " << start < Config; + typedef Ingredients Ing; + Ing myIngredients; + myIngredients.setBoxX(256); + myIngredients.setBoxY(256); + myIngredients.setBoxZ(256); + myIngredients.setPeriodicX(1); + myIngredients.setPeriodicY(1); + myIngredients.setPeriodicZ(1); + myIngredients.modifyBondset().addBFMclassicBondset(); + myIngredients.synchronize(); + TaskManager taskmanager; + taskmanager.addUpdater( new UpdaterAddTMDoubleStars(myIngredients,1, nSegments, nRings, functionality ),0); + taskmanager.addAnalyzer(new AnalyzerWriteBfmFile("config.bfm", myIngredients, AnalyzerWriteBfmFile::APPEND) ); + taskmanager.initialize(); + taskmanager.run(1); + taskmanager.cleanup(); + + std::cout << "Read in conformation and go on to bring it into equilibrium forces..." < Config2; + typedef Ingredients Ing2; + Ing2 myIngredients2; + + myIngredients2.setBoxX(myIngredients.getBoxX()); + myIngredients2.setBoxY(myIngredients.getBoxY()); + myIngredients2.setBoxZ(myIngredients.getBoxZ()); + myIngredients2.setPeriodicX(myIngredients.isPeriodicX()); + myIngredients2.setPeriodicY(myIngredients.isPeriodicY()); + myIngredients2.setPeriodicZ(myIngredients.isPeriodicZ()); + myIngredients2.modifyMolecules().resize(myIngredients.getMolecules().size()); + myIngredients2.modifyMolecules().setAge(myIngredients.getMolecules().getAge()); + + for(size_t i = 0; i< myIngredients.getMolecules().size();i++){ + myIngredients2.modifyMolecules()[i].setMovableTag(myIngredients.modifyMolecules()[i].getMovableTag()); + myIngredients2.modifyMolecules()[i].modifyVector3D()=myIngredients.getMolecules()[i].getVector3D(); + for (size_t j = 0 ; j < myIngredients.getMolecules().getNumLinks(i);j++){ + uint32_t neighbor(myIngredients.getMolecules().getNeighborIdx(i,j)); + if( ! myIngredients2.getMolecules().areConnected(i,neighbor) ) + myIngredients2.modifyMolecules().connect(i,neighbor); + } + } + + myIngredients2.synchronize(); + + TaskManager taskmanager2; + taskmanager2.addUpdater( new UpdaterAffineDeformation(myIngredients2, stretching_factor),0 ); + //read bonds and positions stepwise + auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold,0.95) ; + updater->setFilename(feCurve); + updater->setRelaxationParameter(relaxationParameter); + auto updater2 = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; + if ( gauss == 0 ){ + std::cout << "IdealReferenceForceEquilibrium: add UpdaterForceBalancedPosition(myIngredients2, threshold) \n"; + taskmanager2.addUpdater( updater ); + }else if( gauss == 1 ){ + std::cout << "IdealReferenceForceEquilibrium: add UpdaterForceBalancedPosition(myIngredients2, threshold) \n"; + taskmanager2.addUpdater( updater2 ); + } + + taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,outputDataPos, outputDataDist)); + //initialize and run + taskmanager2.initialize(); + taskmanager2.run(); + if(gauss > 1) + taskmanager2.run(1); + taskmanager2.cleanup(); + + } + catch(std::exception& e){ + std::cerr<<"Error:\n" + < Date: Thu, 2 Dec 2021 11:48:03 +0100 Subject: [PATCH 54/70] bugfix in projects/IdealReference2ForceEquilibrium.cpp and add affine deformation for the standard force equilibrium --- projects/ForceEquilibrium.cpp | 69 +++++++++----------- projects/IdealReference2ForceEquilibrium.cpp | 4 +- 2 files changed, 33 insertions(+), 40 deletions(-) diff --git a/projects/ForceEquilibrium.cpp b/projects/ForceEquilibrium.cpp index e92e1fd..403598b 100644 --- a/projects/ForceEquilibrium.cpp +++ b/projects/ForceEquilibrium.cpp @@ -52,7 +52,7 @@ along with LeMonADE. If not, see . #include #include #include - +#include int main(int argc, char* argv[]){ try{ @@ -68,18 +68,20 @@ int main(int argc, char* argv[]){ double stepwidth(1.0); double minConversion(50.0); bool custom(true); + double stretching_factor(1.0); bool showHelp = false; auto parser - = clara::detail::Opt( inputBFM, "inputBFM (=inconfig.bfm)" ) ["-i"]["--input" ] ("(required)Input filename of the bfm file" ).required() + = clara::detail::Opt( inputBFM, "inputBFM (=inconfig.bfm)" ) ["-i"]["--input" ] ("(required)Input filename of the bfm file" ).required() // | clara::detail::Opt( inputConnection, "inputConnection (=BondCreationBreaking.dat)" ) ["-d"]["--inputConnection"] ("used for the time development of the topology. " ).required() - | clara::detail::Opt( outputDataPos, "outputDataPos (=CrosslinkPosition.dat)" ) ["-o"]["--outputPos" ] ("(optional) Output filename of the crosslink ID and the equilibrium Position.").optional() - | clara::detail::Opt( outputDataDist, "outputDataDist (=ChainExtensionDistribution.dat)") ["-c"]["--outputDist" ] ("(optional) Output filename of the chain extension distribution." ).optional() - | clara::detail::Opt( stepwidth, "stepwidth" ) ["-s"]["--stepwidth" ] ("(optional) Width for the increase in percentage. Default: 1%." ).optional() - | clara::detail::Opt( minConversion, "minConversion" ) ["-u"]["--minConversion" ] ("(optional) Minimum conversion to be read in. Default: 50%." ).optional() - | clara::detail::Opt( threshold, "threshold" ) ["-t"]["--threshold" ] ("(optional) Threshold of the average shift. Default 0.5 ." ).optional() - | clara::detail::Opt( feCurve, "feCurve (="")" ) ["-f"]["--feCurve" ] ("(optional) Force-Extension curve. Default \"\"." ).optional() - | clara::detail::Opt( relaxationParameter, "relaxationParameter (=10)" ) ["-r"]["--relax" ] ("(optional) Relaxation parameter. Default 10.0 ." ).optional() + | clara::detail::Opt( outputDataPos, "outputDataPos (=CrosslinkPosition.dat)" ) ["-o"]["--outputPos" ] ("(optional) Output filename of the crosslink ID and the equilibrium Position.").optional() + | clara::detail::Opt( outputDataDist, "outputDataDist (=ChainExtensionDistribution.dat)") ["-c"]["--outputDist" ] ("(optional) Output filename of the chain extension distribution." ).optional() + | clara::detail::Opt( stepwidth, "stepwidth" ) ["-s"]["--stepwidth" ] ("(optional) Width for the increase in percentage. Default: 1%." ).optional() + | clara::detail::Opt( minConversion, "minConversion" ) ["-u"]["--minConversion" ] ("(optional) Minimum conversion to be read in. Default: 50%." ).optional() + | clara::detail::Opt( threshold, "threshold" ) ["-t"]["--threshold" ] ("(optional) Threshold of the average shift. Default 0.5 ." ).optional() + | clara::detail::Opt( stretching_factor, "stretching_factor (=1)" ) ["-l"]["--stretching_factor"] ("(optional) Stretching factor for uniaxial deformation. Default 1.0 ." ).optional() + | clara::detail::Opt( feCurve, "feCurve (="")" ) ["-f"]["--feCurve" ] ("(optional) Force-Extension curve. Default \"\"." ).optional() + | clara::detail::Opt( relaxationParameter, "relaxationParameter (=10)" ) ["-r"]["--relax" ] ("(optional) Relaxation parameter. Default 10.0 ." ).optional() | clara::Help( showHelp ); auto result = parser.parse( clara::Args( argc, argv ) ); @@ -100,6 +102,7 @@ int main(int argc, char* argv[]){ std::cout << "minConversion : " << minConversion << std::endl; std::cout << "threshold : " << threshold << std::endl; std::cout << "feCurve : " << feCurve << std::endl; + std::cout << "stretching_factor : " << stretching_factor << std::endl; } if ( feCurve.empty() ) custom=false; @@ -156,35 +159,25 @@ int main(int argc, char* argv[]){ } myIngredients2.synchronize(); - - - if(custom){ - TaskManager taskmanager2; - //read bonds and positions stepwise - // taskmanager2.addUpdater( new UpdaterReadCrosslinkConnections(myIngredients2, inputConnection, stepwidth, minConversion) ); - std::cout << "Use custom force-extension curve\n"; - auto forceUpdater = new UpdaterForceBalancedPosition(myIngredients2, threshold); - forceUpdater->setFilename(feCurve); - forceUpdater->setRelaxationParameter(relaxationParameter); - taskmanager2.addUpdater( forceUpdater ); - taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,outputDataPos, outputDataDist)); - //initialize and run - taskmanager2.initialize(); - taskmanager2.run(1); - taskmanager2.cleanup(); - } else { - TaskManager taskmanager2; - //read bonds and positions stepwise - // taskmanager2.addUpdater( new UpdaterReadCrosslinkConnections(myIngredients2, inputConnection, stepwidth, minConversion) ); - std::cout << "Use gaussian force-extension relation\n"; - auto forceUpdater = new UpdaterForceBalancedPosition(myIngredients2, threshold); - taskmanager2.addUpdater( forceUpdater ); - taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,outputDataPos, outputDataDist)); - //initialize and run - taskmanager2.initialize(); - taskmanager2.run(1); - taskmanager2.cleanup(); - } + TaskManager taskmanager2; + taskmanager2.addUpdater( new UpdaterAffineDeformation(myIngredients2, stretching_factor),0 ); + //read bonds and positions stepwise + auto forceUpdater = new UpdaterForceBalancedPosition(myIngredients2, threshold); + forceUpdater->setFilename(feCurve); + forceUpdater->setRelaxationParameter(relaxationParameter); + auto forceUpdater2 = new UpdaterForceBalancedPosition(myIngredients2, threshold); + if(custom){ + std::cout << "Use custom force-extension curve\n"; + taskmanager2.addUpdater( forceUpdater ); + }else{ + std::cout << "Use gaussian force-extension relation\n"; + taskmanager2.addUpdater( forceUpdater2 ); + } + taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,outputDataPos, outputDataDist)); + //initialize and run + taskmanager2.initialize(); + taskmanager2.run(1); + taskmanager2.cleanup(); } catch(std::exception& e){ std::cerr<<"Error:\n" diff --git a/projects/IdealReference2ForceEquilibrium.cpp b/projects/IdealReference2ForceEquilibrium.cpp index 9322e1f..b361051 100644 --- a/projects/IdealReference2ForceEquilibrium.cpp +++ b/projects/IdealReference2ForceEquilibrium.cpp @@ -120,7 +120,7 @@ int main(int argc, char* argv[]){ /////////////////////////////////////////////////////////////////////////////// //Read in th last Config typedef LOKI_TYPELIST_2(FeatureFixedMonomers,FeatureMoleculesIO) Features; - typedef ConfigureSystem Config; + typedef ConfigureSystem Config; typedef Ingredients Ing; Ing myIngredients; myIngredients.setBoxX(256); @@ -141,7 +141,7 @@ int main(int argc, char* argv[]){ std::cout << "Read in conformation and go on to bring it into equilibrium forces..." < Config2; + typedef ConfigureSystem Config2; typedef Ingredients Ing2; Ing2 myIngredients2; From 9c098ed68f097bc2bd8886c33a11eb21cda2476b Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Thu, 2 Dec 2021 12:10:57 +0100 Subject: [PATCH 55/70] add damping factor as command line option --- projects/ForceEquilibrium.cpp | 7 +++++-- projects/TendomerNetworkForceEquilibrium.cpp | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/projects/ForceEquilibrium.cpp b/projects/ForceEquilibrium.cpp index 403598b..93457b5 100644 --- a/projects/ForceEquilibrium.cpp +++ b/projects/ForceEquilibrium.cpp @@ -69,6 +69,7 @@ int main(int argc, char* argv[]){ double minConversion(50.0); bool custom(true); double stretching_factor(1.0); + double dampingfactor(1.0); bool showHelp = false; auto parser @@ -82,6 +83,7 @@ int main(int argc, char* argv[]){ | clara::detail::Opt( stretching_factor, "stretching_factor (=1)" ) ["-l"]["--stretching_factor"] ("(optional) Stretching factor for uniaxial deformation. Default 1.0 ." ).optional() | clara::detail::Opt( feCurve, "feCurve (="")" ) ["-f"]["--feCurve" ] ("(optional) Force-Extension curve. Default \"\"." ).optional() | clara::detail::Opt( relaxationParameter, "relaxationParameter (=10)" ) ["-r"]["--relax" ] ("(optional) Relaxation parameter. Default 10.0 ." ).optional() + | clara::detail::Opt( dampingfactor, "damping (=1)" ) ["-d"]["--damping" ] ("(optional) Damping factor after 1E3MCS. Default 1.0." ).optional() | clara::Help( showHelp ); auto result = parser.parse( clara::Args( argc, argv ) ); @@ -99,6 +101,7 @@ int main(int argc, char* argv[]){ std::cout << "inputBFM : " << inputBFM << std::endl; // std::cout << "inputConnection : " << inputConnection << std::endl; std::cout << "stepwidth : " << stepwidth << std::endl; + std::cout << "dampingfactor : " << dampingfactor << std::endl; std::cout << "minConversion : " << minConversion << std::endl; std::cout << "threshold : " << threshold << std::endl; std::cout << "feCurve : " << feCurve << std::endl; @@ -162,10 +165,10 @@ int main(int argc, char* argv[]){ TaskManager taskmanager2; taskmanager2.addUpdater( new UpdaterAffineDeformation(myIngredients2, stretching_factor),0 ); //read bonds and positions stepwise - auto forceUpdater = new UpdaterForceBalancedPosition(myIngredients2, threshold); + auto forceUpdater = new UpdaterForceBalancedPosition(myIngredients2, threshold,dampingfactor); forceUpdater->setFilename(feCurve); forceUpdater->setRelaxationParameter(relaxationParameter); - auto forceUpdater2 = new UpdaterForceBalancedPosition(myIngredients2, threshold); + auto forceUpdater2 = new UpdaterForceBalancedPosition(myIngredients2, threshold,dampingfactor); if(custom){ std::cout << "Use custom force-extension curve\n"; taskmanager2.addUpdater( forceUpdater ); diff --git a/projects/TendomerNetworkForceEquilibrium.cpp b/projects/TendomerNetworkForceEquilibrium.cpp index f6124e5..2f857a5 100644 --- a/projects/TendomerNetworkForceEquilibrium.cpp +++ b/projects/TendomerNetworkForceEquilibrium.cpp @@ -69,6 +69,7 @@ int main(int argc, char* argv[]){ double factor(0.995); double stretching_factor(1.0); uint32_t gauss(false); + double dampingfactor(1.0); bool showHelp = false; auto parser @@ -80,6 +81,7 @@ int main(int argc, char* argv[]){ | clara::detail::Opt( feCurve, "feCurve (="")" ) ["-f"]["--feCurve" ] ("(optional) Force-Extension curve. Default \"\"." ).required() | clara::detail::Opt( relaxationParameter, "relaxationParameter (=10)" ) ["-r"]["--relax" ] ("(optional) Relaxation parameter. Default 10.0 ." ).optional() | clara::detail::Opt( gauss, "gauss" ) ["-g"]["--gauss" ] ("(optional) Deforma with a Gaussian deformation behaviour. Default 1.0 ." ).optional() + | clara::detail::Opt( dampingfactor, "damping (=1)" ) ["-d"]["--damping" ] ("(optional) Damping factor after 1E3MCS. Default 1.0." ).optional() | clara::Help( showHelp ); auto result = parser.parse( clara::Args( argc, argv ) ); @@ -96,6 +98,7 @@ int main(int argc, char* argv[]){ std::cout << "outputDataDist : " << outputDataDist << std::endl; std::cout << "inputBFM : " << inputBFM << std::endl; std::cout << "threshold : " << threshold << std::endl; + std::cout << "dampingfactor : " << dampingfactor << std::endl; std::cout << "feCurve : " << feCurve << std::endl; std::cout << "gauss : " << gauss << std::endl; std::cout << "stretching_factor : " << stretching_factor << std::endl; @@ -156,10 +159,10 @@ int main(int argc, char* argv[]){ TaskManager taskmanager2; taskmanager2.addUpdater( new UpdaterAffineDeformation(myIngredients2, stretching_factor),0 ); //read bonds and positions stepwise - auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; + auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold, dampingfactor) ; updater->setFilename(feCurve); updater->setRelaxationParameter(relaxationParameter); - auto updater2 = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; + auto updater2 = new UpdaterForceBalancedPosition(myIngredients2, threshold,dampingfactor) ; if ( gauss == 0 ){ std::cout << "TendomerNetworkForceEquilibrium: add UpdaterForceBalancedPosition(myIngredients2, threshold) \n"; taskmanager2.addUpdater( updater ); From 639b358dfdf52e780f84d0f7f57ebe5349c8a876 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Thu, 2 Dec 2021 12:11:18 +0100 Subject: [PATCH 56/70] bugfix: MoveNonLinearForceEquilibrium.h --- .../LeMonADE_PM/updater/moves/MoveNonLinearForceEquilibrium.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/LeMonADE_PM/updater/moves/MoveNonLinearForceEquilibrium.h b/include/LeMonADE_PM/updater/moves/MoveNonLinearForceEquilibrium.h index 940a371..8f9d9ed 100644 --- a/include/LeMonADE_PM/updater/moves/MoveNonLinearForceEquilibrium.h +++ b/include/LeMonADE_PM/updater/moves/MoveNonLinearForceEquilibrium.h @@ -195,7 +195,7 @@ void MoveNonLinearForceEquilibrium::createTable(){ std::string line; getline(in, line); //ignore comments and blank lines - while (line.at(0) == '#' || line.empty() ) //go to next line + if (line.at(0) == '#' || line.empty() ) //go to next line continue; //read data double force, extension; From dcd5bc1d06c9af11ce20e6722a4759608e2624cb Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Wed, 8 Dec 2021 09:03:01 +0100 Subject: [PATCH 57/70] Preequilibrate with Gaussian force extension and afterwards turn on the non-linear --- projects/ForceEquilibrium.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/ForceEquilibrium.cpp b/projects/ForceEquilibrium.cpp index 93457b5..c7a4f27 100644 --- a/projects/ForceEquilibrium.cpp +++ b/projects/ForceEquilibrium.cpp @@ -174,6 +174,7 @@ int main(int argc, char* argv[]){ taskmanager2.addUpdater( forceUpdater ); }else{ std::cout << "Use gaussian force-extension relation\n"; + taskmanager2.addUpdater( new UpdaterForceBalancedPosition(myIngredients2, 0.001); ); taskmanager2.addUpdater( forceUpdater2 ); } taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,outputDataPos, outputDataDist)); From 67326f7f444b6a31a3456de2c130d912714fd060 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Wed, 8 Dec 2021 09:04:49 +0100 Subject: [PATCH 58/70] erase bug... --- projects/ForceEquilibrium.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/ForceEquilibrium.cpp b/projects/ForceEquilibrium.cpp index c7a4f27..3c3264c 100644 --- a/projects/ForceEquilibrium.cpp +++ b/projects/ForceEquilibrium.cpp @@ -174,7 +174,7 @@ int main(int argc, char* argv[]){ taskmanager2.addUpdater( forceUpdater ); }else{ std::cout << "Use gaussian force-extension relation\n"; - taskmanager2.addUpdater( new UpdaterForceBalancedPosition(myIngredients2, 0.001); ); + taskmanager2.addUpdater( new UpdaterForceBalancedPosition(myIngredients2, 0.001) ); taskmanager2.addUpdater( forceUpdater2 ); } taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,outputDataPos, outputDataDist)); From 1a997911953e24490b47157bdcf4abe75612e292 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Wed, 8 Dec 2021 09:08:36 +0100 Subject: [PATCH 59/70] bugfix2 --- projects/ForceEquilibrium.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/ForceEquilibrium.cpp b/projects/ForceEquilibrium.cpp index 3c3264c..d620d94 100644 --- a/projects/ForceEquilibrium.cpp +++ b/projects/ForceEquilibrium.cpp @@ -171,10 +171,10 @@ int main(int argc, char* argv[]){ auto forceUpdater2 = new UpdaterForceBalancedPosition(myIngredients2, threshold,dampingfactor); if(custom){ std::cout << "Use custom force-extension curve\n"; + taskmanager2.addUpdater( new UpdaterForceBalancedPosition(myIngredients2, 0.001) ); taskmanager2.addUpdater( forceUpdater ); }else{ std::cout << "Use gaussian force-extension relation\n"; - taskmanager2.addUpdater( new UpdaterForceBalancedPosition(myIngredients2, 0.001) ); taskmanager2.addUpdater( forceUpdater2 ); } taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,outputDataPos, outputDataDist)); From c114c6654b463aa1aef8183ccd3b84b80c2603a5 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Wed, 8 Dec 2021 10:06:49 +0100 Subject: [PATCH 60/70] equilibrate first with the nonlinear function (if desired), then deform, and then equilibrate again --- projects/ForceEquilibrium.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/projects/ForceEquilibrium.cpp b/projects/ForceEquilibrium.cpp index d620d94..804c4ad 100644 --- a/projects/ForceEquilibrium.cpp +++ b/projects/ForceEquilibrium.cpp @@ -163,15 +163,16 @@ int main(int argc, char* argv[]){ myIngredients2.synchronize(); TaskManager taskmanager2; - taskmanager2.addUpdater( new UpdaterAffineDeformation(myIngredients2, stretching_factor),0 ); - //read bonds and positions stepwise auto forceUpdater = new UpdaterForceBalancedPosition(myIngredients2, threshold,dampingfactor); forceUpdater->setFilename(feCurve); forceUpdater->setRelaxationParameter(relaxationParameter); auto forceUpdater2 = new UpdaterForceBalancedPosition(myIngredients2, threshold,dampingfactor); + if(custom){ + taskmanager2.addUpdater( forceUpdater ); + taskmanager2.addUpdater( new UpdaterAffineDeformation(myIngredients2, stretching_factor),0 ); + //read bonds and positions stepwise if(custom){ std::cout << "Use custom force-extension curve\n"; - taskmanager2.addUpdater( new UpdaterForceBalancedPosition(myIngredients2, 0.001) ); taskmanager2.addUpdater( forceUpdater ); }else{ std::cout << "Use gaussian force-extension relation\n"; From 02b63b11540174057254cec577b75c7e0d8713d0 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Wed, 8 Dec 2021 10:07:48 +0100 Subject: [PATCH 61/70] fix --- projects/ForceEquilibrium.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/ForceEquilibrium.cpp b/projects/ForceEquilibrium.cpp index 804c4ad..14aff75 100644 --- a/projects/ForceEquilibrium.cpp +++ b/projects/ForceEquilibrium.cpp @@ -167,7 +167,7 @@ int main(int argc, char* argv[]){ forceUpdater->setFilename(feCurve); forceUpdater->setRelaxationParameter(relaxationParameter); auto forceUpdater2 = new UpdaterForceBalancedPosition(myIngredients2, threshold,dampingfactor); - if(custom){ + if(custom) taskmanager2.addUpdater( forceUpdater ); taskmanager2.addUpdater( new UpdaterAffineDeformation(myIngredients2, stretching_factor),0 ); //read bonds and positions stepwise From b653f84b8ed97d6f7096f1daed407638d0ddd60b Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Wed, 8 Dec 2021 10:16:58 +0100 Subject: [PATCH 62/70] need to move the affine deformationfrom the initialize to the execute --- include/LeMonADE_PM/updater/UpdaterAffineDeformation.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h b/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h index 4629f78..85d1575 100644 --- a/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h +++ b/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h @@ -52,8 +52,8 @@ class UpdaterAffineDeformation:public AbstractUpdater << "stretching factor in yz = " << stretching_factor_XY << "\n"; }; - virtual void initialize(); - virtual bool execute(){return false;}; + virtual void initialize(){}; + virtual bool execute(); virtual void cleanup(){}; private: @@ -69,7 +69,7 @@ class UpdaterAffineDeformation:public AbstractUpdater } }; template -void UpdaterAffineDeformation::initialize(){ +bool UpdaterAffineDeformation::execute(){ std::cout << "UpdaterAffineDeformation::initialize():"<< std::endl; //adjusting the box size is not neccessary, because it is used only once in the FeatureCrosslinkConnections* //there the jump vectors are calculated From 3be2f2180260260d56fde6ffb38ec7808124da7e Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Wed, 8 Dec 2021 10:36:02 +0100 Subject: [PATCH 63/70] slowly increase the stretching factor to achieve a conversoin for large values --- projects/ForceEquilibrium.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/projects/ForceEquilibrium.cpp b/projects/ForceEquilibrium.cpp index 14aff75..c518be3 100644 --- a/projects/ForceEquilibrium.cpp +++ b/projects/ForceEquilibrium.cpp @@ -167,18 +167,23 @@ int main(int argc, char* argv[]){ forceUpdater->setFilename(feCurve); forceUpdater->setRelaxationParameter(relaxationParameter); auto forceUpdater2 = new UpdaterForceBalancedPosition(myIngredients2, threshold,dampingfactor); - if(custom) - taskmanager2.addUpdater( forceUpdater ); - taskmanager2.addUpdater( new UpdaterAffineDeformation(myIngredients2, stretching_factor),0 ); - //read bonds and positions stepwise - if(custom){ - std::cout << "Use custom force-extension curve\n"; - taskmanager2.addUpdater( forceUpdater ); - }else{ - std::cout << "Use gaussian force-extension relation\n"; - taskmanager2.addUpdater( forceUpdater2 ); + + for (auto i=1; i < stretching_factor ; i++){ + if (i>1) + taskmanager2.addUpdater( new UpdaterAffineDeformation(myIngredients2, static_cast(i)/static_cast(i-1.)) ); + //read bonds and positions stepwise + if(custom){ + std::cout << "Use custom force-extension curve\n"; + taskmanager2.addUpdater( forceUpdater ); + }else{ + std::cout << "Use gaussian force-extension relation\n"; + taskmanager2.addUpdater( forceUpdater2 ); + } + std::stringstream out1,out2; + out1 << "l" << i << "_" << outputDataPos; + out2 << "l" << i << "_" << outputDataDist; + taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,out1.str(), out1.str())); } - taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,outputDataPos, outputDataDist)); //initialize and run taskmanager2.initialize(); taskmanager2.run(1); From e3db13949523940d138c0bc543b68d1767b56fac Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Wed, 8 Dec 2021 11:05:24 +0100 Subject: [PATCH 64/70] remove the decrease of the threshold with decreasing relaxation parameter --- include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h b/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h index d890b36..bdd70e0 100644 --- a/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h +++ b/include/LeMonADE_PM/updater/UpdaterForceBalancedPosition.h @@ -94,7 +94,7 @@ bool UpdaterForceBalancedPosition::execute(){ } if (ing.getMolecules().getAge() %100 == 0 ){ setRelaxationParameter(move.getRelaxationParameter()*decreaseFactor); - threshold*=decreaseFactor; + // threshold*=decreaseFactor; } } std::cout << "Finish equilibration with average shift per cross link < " << avShift << " after " << ing.getMolecules().getAge()-StartMCS < Date: Wed, 8 Dec 2021 12:22:06 +0100 Subject: [PATCH 65/70] correct output filename --- projects/ForceEquilibrium.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/ForceEquilibrium.cpp b/projects/ForceEquilibrium.cpp index c518be3..bd702df 100644 --- a/projects/ForceEquilibrium.cpp +++ b/projects/ForceEquilibrium.cpp @@ -182,7 +182,7 @@ int main(int argc, char* argv[]){ std::stringstream out1,out2; out1 << "l" << i << "_" << outputDataPos; out2 << "l" << i << "_" << outputDataDist; - taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,out1.str(), out1.str())); + taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,out1.str(), out2.str())); } //initialize and run taskmanager2.initialize(); From 4e918eada0c5106e9bfd89ea6ef2dd1ea619e25b Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Thu, 9 Dec 2021 18:21:19 +0100 Subject: [PATCH 66/70] need to change the workflow for the uniaxial deformation --- .../analyzer/AnalyzerEquilbratedPosition.h | 6 +++ .../updater/UpdaterAffineDeformation.h | 6 +++ projects/ForceEquilibrium.cpp | 37 +++++++++++++------ 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/include/LeMonADE_PM/analyzer/AnalyzerEquilbratedPosition.h b/include/LeMonADE_PM/analyzer/AnalyzerEquilbratedPosition.h index 5bcfde1..339a013 100644 --- a/include/LeMonADE_PM/analyzer/AnalyzerEquilbratedPosition.h +++ b/include/LeMonADE_PM/analyzer/AnalyzerEquilbratedPosition.h @@ -76,6 +76,12 @@ template < class IngredientsType > class AnalyzerEquilbratedPosition : public Ab //! just collects the id and the position for the cross links std::vector > CollectAveragePositions(); + + //! setter for the filenames + void setFilenames(std::string outAvPosBasename_, std::string outDistBasename_ ){ + outAvPosBasename= outAvPosBasename_; + outDistBasename=outDistBasename_; + } }; /************************************************************************* diff --git a/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h b/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h index 85d1575..3a716ec 100644 --- a/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h +++ b/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h @@ -56,6 +56,12 @@ class UpdaterAffineDeformation:public AbstractUpdater virtual bool execute(); virtual void cleanup(){}; + //! setter function for the stretching factor + void setStretchingFactor(double stretching_factor_ ) { + stretching_factor=stretching_factor_; + stretching_factor_XY = 1./std::sqrt(stretching_factor) ; + } + private: //!copy of the main container for the system informations IngredientsType& ing; diff --git a/projects/ForceEquilibrium.cpp b/projects/ForceEquilibrium.cpp index bd702df..753bbc9 100644 --- a/projects/ForceEquilibrium.cpp +++ b/projects/ForceEquilibrium.cpp @@ -162,32 +162,45 @@ int main(int argc, char* argv[]){ } myIngredients2.synchronize(); - TaskManager taskmanager2; + // TaskManager taskmanager2; auto forceUpdater = new UpdaterForceBalancedPosition(myIngredients2, threshold,dampingfactor); forceUpdater->setFilename(feCurve); forceUpdater->setRelaxationParameter(relaxationParameter); auto forceUpdater2 = new UpdaterForceBalancedPosition(myIngredients2, threshold,dampingfactor); - + auto uniaxialDeformation = new UpdaterAffineDeformation(myIngredients2, 1.); + auto analyzer = new AnalyzerEquilbratedPosition(myIngredients2,outputDataPos,outputDataDist); + forceUpdater->initialize(); + forceUpdater2->initialize(); + uniaxialDeformation->initialize(); + analyzer->initialize(); + for (auto i=1; i < stretching_factor ; i++){ - if (i>1) - taskmanager2.addUpdater( new UpdaterAffineDeformation(myIngredients2, static_cast(i)/static_cast(i-1.)) ); + if (i>1){ + uniaxialDeformation->setStretchingFactor(static_cast(i)/static_cast(i-1.)); + uniaxialDeformation->execute(); + } //read bonds and positions stepwise if(custom){ std::cout << "Use custom force-extension curve\n"; - taskmanager2.addUpdater( forceUpdater ); + // taskmanager2.addUpdater( forceUpdater ); + forceUpdater->execute(); }else{ std::cout << "Use gaussian force-extension relation\n"; - taskmanager2.addUpdater( forceUpdater2 ); + // taskmanager2.addUpdater( forceUpdater2 ); + forceUpdater2->execute(); } std::stringstream out1,out2; - out1 << "l" << i << "_" << outputDataPos; + out1 << "l" << i << "_" << outputDataPos; out2 << "l" << i << "_" << outputDataDist; - taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,out1.str(), out2.str())); + analyzer->setFilenames(out1.str(), out2.str()); + analyzer->execute(); + // taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,out1.str(), out2.str())); } - //initialize and run - taskmanager2.initialize(); - taskmanager2.run(1); - taskmanager2.cleanup(); + forceUpdater->cleanup(); + forceUpdater2->cleanup(); + uniaxialDeformation->cleanup(); + analyzer->cleanup(); + // taskmanager2.cleanup(); } catch(std::exception& e){ std::cerr<<"Error:\n" From 564dc7a2366afd5d1ec093605c1efe1ca2f3e615 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Mon, 13 Dec 2021 10:45:24 +0100 Subject: [PATCH 67/70] clean up the file ForceEquilibrium.cpp --- projects/ForceEquilibrium.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/projects/ForceEquilibrium.cpp b/projects/ForceEquilibrium.cpp index 753bbc9..c64fcd1 100644 --- a/projects/ForceEquilibrium.cpp +++ b/projects/ForceEquilibrium.cpp @@ -162,7 +162,6 @@ int main(int argc, char* argv[]){ } myIngredients2.synchronize(); - // TaskManager taskmanager2; auto forceUpdater = new UpdaterForceBalancedPosition(myIngredients2, threshold,dampingfactor); forceUpdater->setFilename(feCurve); forceUpdater->setRelaxationParameter(relaxationParameter); @@ -182,11 +181,9 @@ int main(int argc, char* argv[]){ //read bonds and positions stepwise if(custom){ std::cout << "Use custom force-extension curve\n"; - // taskmanager2.addUpdater( forceUpdater ); forceUpdater->execute(); }else{ std::cout << "Use gaussian force-extension relation\n"; - // taskmanager2.addUpdater( forceUpdater2 ); forceUpdater2->execute(); } std::stringstream out1,out2; @@ -194,13 +191,11 @@ int main(int argc, char* argv[]){ out2 << "l" << i << "_" << outputDataDist; analyzer->setFilenames(out1.str(), out2.str()); analyzer->execute(); - // taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,out1.str(), out2.str())); } forceUpdater->cleanup(); forceUpdater2->cleanup(); uniaxialDeformation->cleanup(); analyzer->cleanup(); - // taskmanager2.cleanup(); } catch(std::exception& e){ std::cerr<<"Error:\n" From 955c7016f5dfadea9229b3f96eb05e37373e0259 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Mon, 17 Jan 2022 21:59:23 +0100 Subject: [PATCH 68/70] add possibility for a prestrain factor in the three spatial directions --- .../updater/UpdaterAffineDeformation.h | 21 ++++- projects/ForceEquilibrium.cpp | 92 ++++++++++++------- projects/TendomerNetworkForceEquilibrium.cpp | 17 +++- 3 files changed, 90 insertions(+), 40 deletions(-) diff --git a/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h b/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h index 3a716ec..cbb49d1 100644 --- a/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h +++ b/include/LeMonADE_PM/updater/UpdaterAffineDeformation.h @@ -45,11 +45,20 @@ class UpdaterAffineDeformation:public AbstractUpdater { public: //! constructor for UpdaterAffineDeformation - UpdaterAffineDeformation(IngredientsType& ing_, double stretching_factor_ ): - ing(ing_),stretching_factor(stretching_factor_),stretching_factor_XY(1./std::sqrt(stretching_factor)){ + UpdaterAffineDeformation(IngredientsType& ing_, double stretching_factor_, double prestrain_factorX_=1, double prestrain_factorY_=1, double prestrain_factorZ_=1 ): + ing(ing_), + stretching_factor(stretching_factor_), + stretching_factor_XY(1./std::sqrt(stretching_factor)), + prestrain_factorX(prestrain_factorX_), + prestrain_factorY(prestrain_factorY_), + prestrain_factorZ(prestrain_factorZ_) + { std::cout << "UpdaterAffineDeformation::constructor:\n" << "stretching factor = " << stretching_factor << "\n" - << "stretching factor in yz = " << stretching_factor_XY << "\n"; + << "stretching factor in yz = " << stretching_factor_XY << "\n" + << "prestrain factor in x = " << prestrain_factorX << "\n" + << "prestrain factor in y = " << prestrain_factorY << "\n" + << "prestrain factor in z = " << prestrain_factorZ << "\n"; }; virtual void initialize(){}; @@ -69,9 +78,13 @@ class UpdaterAffineDeformation:public AbstractUpdater //! threshold for the certainty double stretching_factor; double stretching_factor_XY; + //! factors for a prestrain or a correction factor for the elastic inbalance in the spatial direction + double prestrain_factorX,prestrain_factorY,prestrain_factorZ; VectorDouble3 deform( VectorDouble3 vec ){ - return VectorDouble3(vec.getX()*stretching_factor,vec.getY()*stretching_factor_XY,vec.getZ()*stretching_factor_XY); + return VectorDouble3(vec.getX()*stretching_factor *prestrain_factorX, + vec.getY()*stretching_factor_XY*prestrain_factorY, + vec.getZ()*stretching_factor_XY*prestrain_factorZ); } }; template diff --git a/projects/ForceEquilibrium.cpp b/projects/ForceEquilibrium.cpp index c64fcd1..c8c4534 100644 --- a/projects/ForceEquilibrium.cpp +++ b/projects/ForceEquilibrium.cpp @@ -70,6 +70,9 @@ int main(int argc, char* argv[]){ bool custom(true); double stretching_factor(1.0); double dampingfactor(1.0); + double prestrainFactorX(1.0); + double prestrainFactorY(1.0); + double prestrainFactorZ(1.0); bool showHelp = false; auto parser @@ -84,10 +87,13 @@ int main(int argc, char* argv[]){ | clara::detail::Opt( feCurve, "feCurve (="")" ) ["-f"]["--feCurve" ] ("(optional) Force-Extension curve. Default \"\"." ).optional() | clara::detail::Opt( relaxationParameter, "relaxationParameter (=10)" ) ["-r"]["--relax" ] ("(optional) Relaxation parameter. Default 10.0 ." ).optional() | clara::detail::Opt( dampingfactor, "damping (=1)" ) ["-d"]["--damping" ] ("(optional) Damping factor after 1E3MCS. Default 1.0." ).optional() + | clara::detail::Opt( prestrainFactorX, "prestrainFactorX (=1)" ) ["-x"]["--prestrainFactorX" ] ("(optional) Prestrain factor in X. Default 1.0." ).optional() + | clara::detail::Opt( prestrainFactorY, "prestrainFactorY (=1)" ) ["-y"]["--prestrainFactorY" ] ("(optional) Prestrain factor in Y. Default 1.0." ).optional() + | clara::detail::Opt( prestrainFactorZ, "prestrainFactorZ (=1)" ) ["-z"]["--prestrainFactorZ" ] ("(optional) Prestrain factor in Z. Default 1.0." ).optional() | clara::Help( showHelp ); auto result = parser.parse( clara::Args( argc, argv ) ); - + if ( feCurve.empty() ) custom=false; if( !result ) { std::cerr << "Error in command line: " << result.errorMessage() << std::endl; exit(1); @@ -99,15 +105,18 @@ int main(int argc, char* argv[]){ std::cout << "outputData : " << outputDataPos << std::endl; std::cout << "outputDataDist : " << outputDataDist << std::endl; std::cout << "inputBFM : " << inputBFM << std::endl; - // std::cout << "inputConnection : " << inputConnection << std::endl; + std::cout << "custom FE : " << custom << std::endl; std::cout << "stepwidth : " << stepwidth << std::endl; std::cout << "dampingfactor : " << dampingfactor << std::endl; std::cout << "minConversion : " << minConversion << std::endl; std::cout << "threshold : " << threshold << std::endl; std::cout << "feCurve : " << feCurve << std::endl; std::cout << "stretching_factor : " << stretching_factor << std::endl; + std::cout << "prestrainFactorX : " << prestrainFactorX << std::endl; + std::cout << "prestrainFactorY : " << prestrainFactorY << std::endl; + std::cout << "prestrainFactorZ : " << prestrainFactorZ << std::endl; } - if ( feCurve.empty() ) custom=false; + RandomNumberGenerators rng; @@ -163,39 +172,58 @@ int main(int argc, char* argv[]){ myIngredients2.synchronize(); auto forceUpdater = new UpdaterForceBalancedPosition(myIngredients2, threshold,dampingfactor); - forceUpdater->setFilename(feCurve); + if(custom) + forceUpdater->setFilename(feCurve); forceUpdater->setRelaxationParameter(relaxationParameter); auto forceUpdater2 = new UpdaterForceBalancedPosition(myIngredients2, threshold,dampingfactor); - auto uniaxialDeformation = new UpdaterAffineDeformation(myIngredients2, 1.); + auto uniaxialDeformation = new UpdaterAffineDeformation(myIngredients2, stretching_factor,prestrainFactorX,prestrainFactorY,prestrainFactorZ); + auto analyzer = new AnalyzerEquilbratedPosition(myIngredients2,outputDataPos,outputDataDist); - forceUpdater->initialize(); - forceUpdater2->initialize(); - uniaxialDeformation->initialize(); - analyzer->initialize(); - - for (auto i=1; i < stretching_factor ; i++){ - if (i>1){ - uniaxialDeformation->setStretchingFactor(static_cast(i)/static_cast(i-1.)); - uniaxialDeformation->execute(); - } - //read bonds and positions stepwise - if(custom){ - std::cout << "Use custom force-extension curve\n"; - forceUpdater->execute(); - }else{ - std::cout << "Use gaussian force-extension relation\n"; - forceUpdater2->execute(); - } - std::stringstream out1,out2; - out1 << "l" << i << "_" << outputDataPos; - out2 << "l" << i << "_" << outputDataDist; - analyzer->setFilenames(out1.str(), out2.str()); - analyzer->execute(); + + TaskManager taskmanager2; + taskmanager2.addUpdater( uniaxialDeformation,0 ); + //read bonds and positions stepwise + if(custom){ + std::cout << "Use custom force-extension curve\n"; + taskmanager2.addUpdater( forceUpdater ); + }else{ + std::cout << "Use gaussian force-extension relation\n"; + taskmanager2.addUpdater( forceUpdater2 ); } - forceUpdater->cleanup(); - forceUpdater2->cleanup(); - uniaxialDeformation->cleanup(); - analyzer->cleanup(); + taskmanager2.addAnalyzer(analyzer); + //initialize and run + taskmanager2.initialize(); + taskmanager2.run(1); + taskmanager2.cleanup(); + + // forceUpdater->initialize(); + // forceUpdater2->initialize(); + // uniaxialDeformation->initialize(); + // analyzer->initialize(); + + // for (auto i=1; i < stretching_factor ; i++){ + // if (i>1){ + // uniaxialDeformation->setStretchingFactor(static_cast(i)/static_cast(i-1.)); + // uniaxialDeformation->execute(); + // } + // //read bonds and positions stepwise + // if(custom){ + // std::cout << "Use custom force-extension curve\n"; + // forceUpdater->execute(); + // }else{ + // std::cout << "Use gaussian force-extension relation\n"; + // forceUpdater2->execute(); + // } + // std::stringstream out1,out2; + // out1 << "l" << i << "_" << outputDataPos; + // out2 << "l" << i << "_" << outputDataDist; + // analyzer->setFilenames(out1.str(), out2.str()); + // analyzer->execute(); + // } + // forceUpdater->cleanup(); + // forceUpdater2->cleanup(); + // uniaxialDeformation->cleanup(); + // analyzer->cleanup(); } catch(std::exception& e){ std::cerr<<"Error:\n" diff --git a/projects/TendomerNetworkForceEquilibrium.cpp b/projects/TendomerNetworkForceEquilibrium.cpp index 2f857a5..e921313 100644 --- a/projects/TendomerNetworkForceEquilibrium.cpp +++ b/projects/TendomerNetworkForceEquilibrium.cpp @@ -70,6 +70,9 @@ int main(int argc, char* argv[]){ double stretching_factor(1.0); uint32_t gauss(false); double dampingfactor(1.0); + double prestrainFactorX(1.0); + double prestrainFactorY(1.0); + double prestrainFactorZ(1.0); bool showHelp = false; auto parser @@ -82,6 +85,9 @@ int main(int argc, char* argv[]){ | clara::detail::Opt( relaxationParameter, "relaxationParameter (=10)" ) ["-r"]["--relax" ] ("(optional) Relaxation parameter. Default 10.0 ." ).optional() | clara::detail::Opt( gauss, "gauss" ) ["-g"]["--gauss" ] ("(optional) Deforma with a Gaussian deformation behaviour. Default 1.0 ." ).optional() | clara::detail::Opt( dampingfactor, "damping (=1)" ) ["-d"]["--damping" ] ("(optional) Damping factor after 1E3MCS. Default 1.0." ).optional() + | clara::detail::Opt( prestrainFactorX, "prestrainFactorX (=1)" ) ["-x"]["--prestrainFactorX" ] ("(optional) Prestrain factor in X. Default 1.0." ).optional() + | clara::detail::Opt( prestrainFactorY, "prestrainFactorY (=1)" ) ["-y"]["--prestrainFactorY" ] ("(optional) Prestrain factor in Y. Default 1.0." ).optional() + | clara::detail::Opt( prestrainFactorZ, "prestrainFactorZ (=1)" ) ["-z"]["--prestrainFactorZ" ] ("(optional) Prestrain factor in Z. Default 1.0." ).optional() | clara::Help( showHelp ); auto result = parser.parse( clara::Args( argc, argv ) ); @@ -102,6 +108,9 @@ int main(int argc, char* argv[]){ std::cout << "feCurve : " << feCurve << std::endl; std::cout << "gauss : " << gauss << std::endl; std::cout << "stretching_factor : " << stretching_factor << std::endl; + std::cout << "prestrainFactorX : " << prestrainFactorX << std::endl; + std::cout << "prestrainFactorY : " << prestrainFactorY << std::endl; + std::cout << "prestrainFactorZ : " << prestrainFactorZ << std::endl; } RandomNumberGenerators rng; // rng.seedDefaultValuesAll(); @@ -157,14 +166,14 @@ int main(int argc, char* argv[]){ myIngredients2.synchronize(); TaskManager taskmanager2; - taskmanager2.addUpdater( new UpdaterAffineDeformation(myIngredients2, stretching_factor),0 ); + taskmanager2.addUpdater( new UpdaterAffineDeformation(myIngredients2, stretching_factor,prestrainFactorX,prestrainFactorY,prestrainFactorZ),0 ); //read bonds and positions stepwise auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold, dampingfactor) ; - updater->setFilename(feCurve); - updater->setRelaxationParameter(relaxationParameter); auto updater2 = new UpdaterForceBalancedPosition(myIngredients2, threshold,dampingfactor) ; if ( gauss == 0 ){ - std::cout << "TendomerNetworkForceEquilibrium: add UpdaterForceBalancedPosition(myIngredients2, threshold) \n"; + updater->setFilename(feCurve); + updater->setRelaxationParameter(relaxationParameter); + std::cout << "TendomerNetworkForceEquilibrium: add UpdaterForceBalancedPosition(myIngredients2, threshold) \n"; taskmanager2.addUpdater( updater ); }else if (gauss == 1 ){ std::cout << "TendomerNetworkForceEquilibrium: add UpdaterForceBalancedPosition(myIngredients2, threshold) \n"; From 3dace3640d0bf200b4505daf04d64484ad956ce4 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Mon, 31 Jan 2022 10:20:15 +0100 Subject: [PATCH 69/70] clean up the repo --- .../AnalyzerConnectionDistributions.h | 128 ------------ .../AnalyzerIntramolecularReactions.h | 168 ---------------- projects/ForceEquilibrium.cpp | 31 +-- projects/IdealReference2ForceEquilibrium.cpp | 3 +- projects/IdealReferenceForceEquilibrium.cpp | 29 ++- projects/IntramolecularReactions.cpp | 170 ---------------- projects/TendomerNetworkExtractActivePart.cpp | 6 +- ...etworkForceEquilibriumConversionSeries.cpp | 186 ------------------ 8 files changed, 19 insertions(+), 702 deletions(-) delete mode 100644 include/LeMonADE_PM/analyzer/AnalyzerConnectionDistributions.h delete mode 100644 include/LeMonADE_PM/analyzer/AnalyzerIntramolecularReactions.h delete mode 100644 projects/IntramolecularReactions.cpp delete mode 100644 projects/TendomerNetworkForceEquilibriumConversionSeries.cpp diff --git a/include/LeMonADE_PM/analyzer/AnalyzerConnectionDistributions.h b/include/LeMonADE_PM/analyzer/AnalyzerConnectionDistributions.h deleted file mode 100644 index 2e43939..0000000 --- a/include/LeMonADE_PM/analyzer/AnalyzerConnectionDistributions.h +++ /dev/null @@ -1,128 +0,0 @@ -/****************************************************************************** - * based on LeMonADE: https://github.com/LeMonADE-project/LeMonADE/ - * author: Toni Müller - * email: mueller-toni@ipfdd.de - * project: Phantom Modulus - *****************************************************************************/ - -#ifndef LEMONADE_PM_ANALYZER_ANALYZERINTRAMOLECULARREACTIONS_H -#define LEMONADE_PM_ANALYZER_ANALYZERINTRAMOLECULARREACTIONS_H - -#include - -#include -#include -#include -#include -#include - -/************************************************************************* - * definition of AnalyzerIntramolecularReactions class - * ***********************************************************************/ - -/** - * @file - * - * @class AnalyzerIntramolecularReactions - * - * @brief Analyzes the connection distribution of chains and cross linker for the whole system, - * the gel and the active part of the gel. - * - * @tparam IngredientsType Ingredients class storing all system information( e.g. monomers, bonds, etc). - */ -template < class IngredientsType > class AnalyzerIntramolecularReactions : public AbstractAnalyzer -{ - -private: - //! typedef for the underlying container holding the monomers - typedef typename IngredientsType::molecules_type molecules_type; - - //! reference to the complete system - const IngredientsType& ingredients; -public: - //! constructor - AnalyzerIntramolecularReactions(const IngredientsType& ingredients_, std::string outputFilename_); - - //! destructor. does nothing - virtual ~AnalyzerIntramolecularReactions(){} - - //! Initializes data structures. Called by TaskManager::initialize() - virtual void initialize(); - - //! Calculates the Rg2 for the current timestep. Called by TaskManager::execute() - virtual bool execute(); - - //! Writes the final results to file - virtual void cleanup(); - - //! name of output file for the average is outputFilePrefix_averages.dat - std::string outputFilename; - - //! save the current values in Rg2TimeSeriesX, etc., to disk - void dumpData(); - - //! calculates the distance between crosslinks and stores IDs, distance vector and chainID - std::vector< std::vector > CalculateDistance(); - - //! just collects the id and the position for the cross links - std::vector > CollectAveragePositions(); -}; - -/************************************************************************* - * implementation of memebers - * ***********************************************************************/ - -/** - * @param ing reference to the object holding all information of the system - * */ -template -AnalyzerIntramolecularReactions::AnalyzerIntramolecularReactions( - const IngredientsType& ingredients_, std::string outputFilename_) -:ingredients(ingredients_) -,outputFilename(outputFilename_) -{} -//////////////////////////////////////////////////////////////////////////////// -/** - * @brief calculates the average distances between monomers and their distribution - * */ -template< class IngredientsType > -void AnalyzerIntramolecularReactions::initialize(){} -/** - * @details - * */ -template< class IngredientsType > -bool AnalyzerIntramolecularReactions::execute() -{ - dumpData(); - return true; -} -template -void AnalyzerIntramolecularReactions::cleanup() -{ - dumpData(); -} - - -template -void AnalyzerIntramolecularReactions::dumpData() -{ - - //output for the equilibrated positions - std::vector< std::vector > CrossLinkPositions=CollectAveragePositions() ; - std::stringstream commentAveragePosition; - commentAveragePosition<<"Created by AnalyzerIntramolecularReactions\n"; - commentAveragePosition<<"conversion nBonds nIntraBonds nBondsGel nIntraBondsGels \n"; - - ResultFormattingTools::writeResultFile( - outputFilename, - ingredients, - CrossLinkPositions, - commentAveragePosition.str() - ); - - -} - -#endif /*LEMONADE_PM_ANALYZER_ANALYZERINTRAMOLECULARREACTIONS_H*/ - - diff --git a/include/LeMonADE_PM/analyzer/AnalyzerIntramolecularReactions.h b/include/LeMonADE_PM/analyzer/AnalyzerIntramolecularReactions.h deleted file mode 100644 index 5a5fb11..0000000 --- a/include/LeMonADE_PM/analyzer/AnalyzerIntramolecularReactions.h +++ /dev/null @@ -1,168 +0,0 @@ -/****************************************************************************** - * based on LeMonADE: https://github.com/LeMonADE-project/LeMonADE/ - * author: Toni Müller - * email: mueller-toni@ipfdd.de - * project:Phantom Modulus - *****************************************************************************/ - -#ifndef LEMONADE_PM_ANALYZER_ANALYZERINTRAMOLECULARREACTIONS_H -#define LEMONADE_PM_ANALYZER_ANALYZERINTRAMOLECULARREACTIONS_H - -#include - -#include -#include -#include -#include -#include - -/************************************************************************* - * definition of AnalyzerIntramolecularReactions class - * ***********************************************************************/ - -/** - * @file - * - * @class AnalyzerIntramolecularReactions - * - * @brief Analyzer counting the intramolecular reactions - * - * @tparam IngredientsType Ingredients class storing all system information( e.g. monomers, bonds, etc). - */ -template < class IngredientsType > class AnalyzerIntramolecularReactions : public AbstractAnalyzer -{ -private: - //! typedef for the underlying container holding the monomers - typedef typename IngredientsType::molecules_type molecules_type; - //! reference to the complete system - const IngredientsType& ingredients; - //!cotnainer holding the information about conversion nBonds nIntraBonds nBondsGel nIntraBondsGels - std::vector > data; - //! name of output file for the average is outputFilePrefix_averages.dat - std::string outputFilename; - //! save the collected data to a file - void dumpData(); - //! iterates over the structure and searches for the intramolecular reactions - void getBiggestCluster(); -public: - //! constructor - AnalyzerIntramolecularReactions(const IngredientsType& ingredients_, std::string outputFilename_); - //! destructor. does nothing - virtual ~AnalyzerIntramolecularReactions(){} - //! nothing needs to be initialized - virtual void initialize(); - //! Runs over the structure and obtains the conversion nBonds nIntraBonds nBondsGel nIntraBondsGels. - virtual bool execute(); - //! Writes the final results to file - virtual void cleanup(); -}; - -/************************************************************************* - * implementation of memebers - * ***********************************************************************/ - -/** - * @param ing reference to the object holding all information of the system - * */ -template -AnalyzerIntramolecularReactions::AnalyzerIntramolecularReactions( - const IngredientsType& ingredients_, std::string outputFilename_) -:ingredients(ingredients_) -,outputFilename(outputFilename_) -{} -//////////////////////////////////////////////////////////////////////////////// -template< class IngredientsType > -void AnalyzerIntramolecularReactions::initialize(){} - -template< class IngredientsType > -bool AnalyzerIntramolecularReactions::execute() -{ - - return true; -} -template -void AnalyzerIntramolecularReactions::cleanup() -{ - dumpData(); -} -template -void AnalyzerIntramolecularReactions::dumpData() -{ - //output for the equilibrated positions - std::stringstream commentAveragePosition; - commentAveragePosition<<"Created by AnalyzerIntramolecularReactions\n"; - commentAveragePosition<<"nTotalBonds="< -void AnalyzerIntramolecularReactions::getBiggestCluster () { - uint32_t nMolecules(0); - std::vector LargestCluster; - const typename IngredientsType::molecules_type& getMolies = ingredients.getMolecules(); - //search largest cluster: use the attribute tag for that - //at first store the initial attributes to reset them after the search - //then color the whole graph. connected parts have the same color - auto nMonomers(getMolies.size()); - std::vector Tag(nMonomers,0); - //color graph - int freeColor(1); - for (auto i=0 ; i < nMonomers;i++){ - std::vector rememberBranch; - rememberBranch.push_back(i); - if(Tag[i] == 0) { - while ( rememberBranch.size() > 0 ){ - auto ID(rememberBranch.back()); - auto color(Tag[ID]); - rememberBranch.pop_back(); - if ( color == 0){ - Tag[ID]=freeColor; - auto nLinks(getMolies.getNumLinks(ID)); - if(nLinks != 0 ){ - for(auto j=0; j < nLinks ; j++){ - auto Neighbor(getMolies.getNeighborIdx(ID,j)); - if( Tag[Neighbor] == 0 ) rememberBranch.push_back(Neighbor); - } - } - } - } - freeColor++; - } - } - freeColor--; - nMolecules=freeColor; - std::cout << "#Molecules=" << nMolecules < > ColoredGraphIDs(freeColor+1,std::vector(0)); - for (auto i=0 ; i < nMonomers;i++){ - uint32_t atti(Tag[i]); - if (atti==0 ){//this should never happen because all monomers should be covered above and colored - std::stringstream error_message; - error_message << "AnalyzerActiveChainDensity::execute(): Found monomer which is not colored! ID is " << i << "\n"; - throw std::runtime_error(error_message.str()); - } - ColoredGraphIDs[atti].push_back(i); - } - auto biggestClusterID(0); - auto biggestClusterSize(ColoredGraphIDs[biggestClusterID].size()); - for (auto i=0; i < freeColor+1 ; i++){ - std::cout << "ClusterID " << i << " cluster size " << ColoredGraphIDs[i].size() << std::endl; - if ( biggestClusterSize < ColoredGraphIDs[i].size() ){ - biggestClusterSize=ColoredGraphIDs[i].size(); - biggestClusterID=i; - } - } - std::cout << "biggest ClusterID " << biggestClusterID << " biggestClusterSize " << biggestClusterSize << std::endl; - LargestCluster=ColoredGraphIDs[biggestClusterID]; - // return LargestCluster; -} - -#endif /*LEMONADE_PM_ANALYZER_ANALYZERINTRAMOLECULARREACTIONS_H*/ - - diff --git a/projects/ForceEquilibrium.cpp b/projects/ForceEquilibrium.cpp index c8c4534..5bdeb86 100644 --- a/projects/ForceEquilibrium.cpp +++ b/projects/ForceEquilibrium.cpp @@ -98,7 +98,7 @@ int main(int argc, char* argv[]){ std::cerr << "Error in command line: " << result.errorMessage() << std::endl; exit(1); }else if(showHelp == true){ - std::cout << "Simulator to connect linear chains with single monomers of certain functionality"<< std::endl; + std::cout << "Standard force equilibration for a end-linked network."<< std::endl; parser.writeToStream(std::cout); exit(0); }else{ @@ -195,35 +195,6 @@ int main(int argc, char* argv[]){ taskmanager2.initialize(); taskmanager2.run(1); taskmanager2.cleanup(); - - // forceUpdater->initialize(); - // forceUpdater2->initialize(); - // uniaxialDeformation->initialize(); - // analyzer->initialize(); - - // for (auto i=1; i < stretching_factor ; i++){ - // if (i>1){ - // uniaxialDeformation->setStretchingFactor(static_cast(i)/static_cast(i-1.)); - // uniaxialDeformation->execute(); - // } - // //read bonds and positions stepwise - // if(custom){ - // std::cout << "Use custom force-extension curve\n"; - // forceUpdater->execute(); - // }else{ - // std::cout << "Use gaussian force-extension relation\n"; - // forceUpdater2->execute(); - // } - // std::stringstream out1,out2; - // out1 << "l" << i << "_" << outputDataPos; - // out2 << "l" << i << "_" << outputDataDist; - // analyzer->setFilenames(out1.str(), out2.str()); - // analyzer->execute(); - // } - // forceUpdater->cleanup(); - // forceUpdater2->cleanup(); - // uniaxialDeformation->cleanup(); - // analyzer->cleanup(); } catch(std::exception& e){ std::cerr<<"Error:\n" diff --git a/projects/IdealReference2ForceEquilibrium.cpp b/projects/IdealReference2ForceEquilibrium.cpp index b361051..40a1f38 100644 --- a/projects/IdealReference2ForceEquilibrium.cpp +++ b/projects/IdealReference2ForceEquilibrium.cpp @@ -97,13 +97,12 @@ int main(int argc, char* argv[]){ std::cerr << "Error in command line: " << result.errorMessage() << std::endl; exit(1); }else if(showHelp == true){ - // std::cout << "Simulator to connect linear chains with single monomers of certain functionality"<< std::endl; + std::cout << "Force equilibration of two a double star, where each chain is replaced effectively by a tendomer."<< std::endl; parser.writeToStream(std::cout); exit(0); }else{ std::cout << "outputData : " << outputDataPos << std::endl; std::cout << "outputDataDist : " << outputDataDist << std::endl; - // std::cout << "inputBFM : " << inputBFM << std::endl; std::cout << "threshold : " << threshold << std::endl; std::cout << "feCurve : " << feCurve << std::endl; std::cout << "gauss : " << gauss << std::endl; diff --git a/projects/IdealReferenceForceEquilibrium.cpp b/projects/IdealReferenceForceEquilibrium.cpp index b3e3cbc..83e404e 100644 --- a/projects/IdealReferenceForceEquilibrium.cpp +++ b/projects/IdealReferenceForceEquilibrium.cpp @@ -98,23 +98,22 @@ int main(int argc, char* argv[]){ auto result = parser.parse( clara::Args( argc, argv ) ); if( !result ) { - std::cerr << "Error in command line: " << result.errorMessage() << std::endl; - exit(1); + std::cerr << "Error in command line: " << result.errorMessage() << std::endl; + exit(1); }else if(showHelp == true){ - // std::cout << "Simulator to connect linear chains with single monomers of certain functionality"<< std::endl; - parser.writeToStream(std::cout); - exit(0); + std::cout << "Force equilibration of a star, where each chain is replaced effectively by a tendomer."<< std::endl; + parser.writeToStream(std::cout); + exit(0); }else{ - std::cout << "outputData : " << outputDataPos << std::endl; - std::cout << "outputDataDist : " << outputDataDist << std::endl; - // std::cout << "inputBFM : " << inputBFM << std::endl; - std::cout << "threshold : " << threshold << std::endl; - std::cout << "feCurve : " << feCurve << std::endl; - std::cout << "gauss : " << gauss << std::endl; - std::cout << "stretching_factor : " << stretching_factor << std::endl; - std::cout << "nSegments : " << nSegments << std::endl; - std::cout << "functionality : " << functionality << std::endl; - std::cout << "nRings : " << nRings << std::endl; + std::cout << "outputData : " << outputDataPos << std::endl; + std::cout << "outputDataDist : " << outputDataDist << std::endl; + std::cout << "threshold : " << threshold << std::endl; + std::cout << "feCurve : " << feCurve << std::endl; + std::cout << "gauss : " << gauss << std::endl; + std::cout << "stretching_factor : " << stretching_factor << std::endl; + std::cout << "nSegments : " << nSegments << std::endl; + std::cout << "functionality : " << functionality << std::endl; + std::cout << "nRings : " << nRings << std::endl; } RandomNumberGenerators rng; // rng.seedDefaultValuesAll(); diff --git a/projects/IntramolecularReactions.cpp b/projects/IntramolecularReactions.cpp deleted file mode 100644 index 7aa6fa5..0000000 --- a/projects/IntramolecularReactions.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/*-------------------------------------------------------------------------------- - ooo L attice-based | - o\.|./o e xtensible | LeMonADE: An Open Source Implementation of the - o\.\|/./o Mon te-Carlo | Bond-Fluctuation-Model for Polymers -oo---0---oo A lgorithm and | - o/./|\.\o D evelopment | Copyright (C) 2013-2015 by - o/.|.\o E nvironment | LeMonADE Principal Developers (see AUTHORS) - ooo | ----------------------------------------------------------------------------------- - -This file is part of LeMonADE. - -LeMonADE 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. - -LeMonADE 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 LeMonADE. If not, see . - ---------------------------------------------------------------------------------*/ - -/****************************************************************************** - * based on LeMonADE: https://github.com/LeMonADE-project/LeMonADE/ - * author: Toni Müller - * email: mueller-toni@ipfdd.de - * project: LeMonADE-Phantom Modulus - *****************************************************************************/ -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - - -int main(int argc, char* argv[]){ - try{ - /////////////////////////////////////////////////////////////////////////////// - ///parse options/// - std::string inputBFM("init.bfm"); - std::string outputData("IntramolecularReactions.dat"); - std::string inputConnection("BondCreationBreaking.dat"); - std::string feCurve(""); - double relaxationParameter(10.); - double threshold(0.5); - double stepwidth(1.0); - double minConversion(50.0); - - bool showHelp = false; - auto parser - = clara::detail::Opt( inputBFM, "inputBFM (=inconfig.bfm)" ) ["-i"]["--input" ] ("(required)Input filename of the bfm file" ).required() - | clara::detail::Opt( inputConnection, "inputConnection (=BondCreationBreaking.dat)" ) ["-d"]["--inputConnection"] ("used for the time development of the topology. " ).required() - | clara::detail::Opt( outputData, "outputData (=IntramolecularReactions.dat)" ) ["-o"]["--outputData" ] ("(optional) Output filename of the crosslink ID and the equilibrium Position.").optional() - | clara::detail::Opt( stepwidth, "stepwidth" ) ["-s"]["--stepwidth" ] ("(optional) Width for the increase in percentage. Default: 1%." ).optional() - | clara::detail::Opt( minConversion, "minConversion" ) ["-u"]["--minConversion" ] ("(optional) Minimum conversion to be read in. Default: 50%." ).optional() - | clara::detail::Opt( threshold, "threshold" ) ["-t"]["--threshold" ] ("(optional) Threshold of the average shift. Default 0.5 ." ).optional() - | clara::detail::Opt( feCurve, "feCurve (="")" ) ["-f"]["--feCurve" ] ("(optional) Force-Extension curve. Default \"\"." ).required() - | clara::detail::Opt( relaxationParameter, "relaxationParameter (=10)" ) ["-r"]["--relax" ] ("(optional) Relaxation parameter. Default 10.0 ." ).optional() - | clara::Help( showHelp ); - - auto result = parser.parse( clara::Args( argc, argv ) ); - - if( !result ) { - std::cerr << "Error in command line: " << result.errorMessage() << std::endl; - exit(1); - }else if(showHelp == true){ - std::cout << "Simulator to connect linear chains with single monomers of certain functionality"<< std::endl; - parser.writeToStream(std::cout); - exit(0); - }else{ - std::cout << "outputData : " << outputData << std::endl; - std::cout << "inputBFM : " << inputBFM << std::endl; - std::cout << "inputConnection : " << inputConnection << std::endl; - std::cout << "stepwidth : " << stepwidth << std::endl; - std::cout << "minConversion : " << minConversion << std::endl; - std::cout << "threshold : " << threshold << std::endl; - std::cout << "feCurve : " << feCurve << std::endl; - } - - /////////////////////////////////////////////////////////////////////////////// - ///end options parsing - /////////////////////////////////////////////////////////////////////////////// - //Read in th last Config - typedef LOKI_TYPELIST_3(FeatureMoleculesIOUnsaveCheck, FeatureLabel, FeatureReactiveBonds) Features; - typedef ConfigureSystem Config; - typedef Ingredients Ing; - Ing myIngredients; - - TaskManager taskmanager; - - taskmanager.addUpdater( new UpdaterReadBfmFile(inputBFM,myIngredients, UpdaterReadBfmFile::READ_LAST_CONFIG_SAVE),0); - - //initialize and run - taskmanager.initialize(); - taskmanager.run(1); - taskmanager.cleanup(); - std::cout << "Read in conformation and go on to bring it into equilibrium forces..." < Config2; - typedef Ingredients Ing2; - Ing2 myIngredients2; - - myIngredients2.setBoxX(myIngredients.getBoxX()); - myIngredients2.setBoxY(myIngredients.getBoxY()); - myIngredients2.setBoxZ(myIngredients.getBoxZ()); - myIngredients2.setPeriodicX(myIngredients.isPeriodicX()); - myIngredients2.setPeriodicY(myIngredients.isPeriodicY()); - myIngredients2.setPeriodicZ(myIngredients.isPeriodicZ()); - myIngredients2.modifyMolecules().resize(myIngredients.getMolecules().size()); - myIngredients2.modifyMolecules().setAge(myIngredients.getMolecules().getAge()); - - myIngredients2.setNumTendomers (myIngredients.getNumTendomers()); - myIngredients2.setNumCrossLinkers (myIngredients.getNumCrossLinkers()); - myIngredients2.setNumMonomersPerChain (myIngredients.getNumMonomersPerChain()); - myIngredients2.setNumLabelsPerTendomerArm(myIngredients.getNumLabelsPerTendomerArm()); - - for(size_t i = 0; i< myIngredients.getMolecules().size();i++){ - myIngredients2.modifyMolecules()[i].modifyVector3D()=myIngredients.getMolecules()[i].getVector3D(); - myIngredients2.modifyMolecules()[i].setReactive(myIngredients.getMolecules()[i].isReactive()); - myIngredients2.modifyMolecules()[i].setNumMaxLinks(myIngredients.getMolecules()[i].getNumMaxLinks()); - for (size_t j = 0 ; j < myIngredients.getMolecules().getNumLinks(i);j++){ - uint32_t neighbor(myIngredients.getMolecules().getNeighborIdx(i,j)); - if( ! myIngredients2.getMolecules().areConnected(i,neighbor) ) - myIngredients2.modifyMolecules().connect(i,neighbor); - } - } - myIngredients2.synchronize(); - - TaskManager taskmanager2; - //read bonds and positions stepwise - taskmanager2.addUpdater( new UpdaterReadCrosslinkConnectionsTendomer(myIngredients2, inputConnection, stepwidth, minConversion) ); - taskmanager2.addAnalyzer(new AnalyzerIntramolecularReactions(myIngredients2, outputData)); - //initialize and run - taskmanager2.initialize(); - taskmanager2.run(); - taskmanager2.cleanup(); - - } - catch(std::exception& e){ - std::cerr<<"Error:\n" - <. - ---------------------------------------------------------------------------------*/ - -/****************************************************************************** - * based on LeMonADE: https://github.com/LeMonADE-project/LeMonADE/ - * author: Toni Müller - * email: mueller-toni@ipfdd.de - * project: LeMonADE-Phantom Modulus - *****************************************************************************/ -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - - -int main(int argc, char* argv[]){ - try{ - /////////////////////////////////////////////////////////////////////////////// - ///parse options/// - std::string inputBFM("init.bfm"); - std::string outputDataPos("CrosslinkPosition.dat"); - std::string outputDataDist("ChainExtensionDistribution.dat"); - std::string inputConnection("BondCreationBreaking.dat"); - std::string feCurve(""); - double relaxationParameter(10.); - double threshold(0.5); - double stepwidth(1.0); - double minConversion(50.0); - - bool showHelp = false; - auto parser - = clara::detail::Opt( inputBFM, "inputBFM (=inconfig.bfm)" ) ["-i"]["--input" ] ("(required)Input filename of the bfm file" ).required() - | clara::detail::Opt( inputConnection, "inputConnection (=BondCreationBreaking.dat)" ) ["-d"]["--inputConnection"] ("used for the time development of the topology. " ).required() - | clara::detail::Opt( outputDataPos, "outputDataPos (=CrosslinkPosition.dat)" ) ["-o"]["--outputPos" ] ("(optional) Output filename of the crosslink ID and the equilibrium Position.").optional() - | clara::detail::Opt( outputDataDist, "outputDataDist (=ChainExtensionDistribution.dat)") ["-c"]["--outputDist" ] ("(optional) Output filename of the chain extension distribution." ).optional() - | clara::detail::Opt( stepwidth, "stepwidth" ) ["-s"]["--stepwidth" ] ("(optional) Width for the increase in percentage. Default: 1%." ).optional() - | clara::detail::Opt( minConversion, "minConversion" ) ["-u"]["--minConversion" ] ("(optional) Minimum conversion to be read in. Default: 50%." ).optional() - | clara::detail::Opt( threshold, "threshold" ) ["-t"]["--threshold" ] ("(optional) Threshold of the average shift. Default 0.5 ." ).optional() - | clara::detail::Opt( feCurve, "feCurve (="")" ) ["-f"]["--feCurve" ] ("(optional) Force-Extension curve. Default \"\"." ).required() - | clara::detail::Opt( relaxationParameter, "relaxationParameter (=10)" ) ["-r"]["--relax" ] ("(optional) Relaxation parameter. Default 10.0 ." ).optional() - | clara::Help( showHelp ); - - auto result = parser.parse( clara::Args( argc, argv ) ); - - if( !result ) { - std::cerr << "Error in command line: " << result.errorMessage() << std::endl; - exit(1); - }else if(showHelp == true){ - std::cout << "Simulator to connect linear chains with single monomers of certain functionality"<< std::endl; - parser.writeToStream(std::cout); - exit(0); - }else{ - std::cout << "outputData : " << outputDataPos << std::endl; - std::cout << "outputDataDist : " << outputDataDist << std::endl; - std::cout << "inputBFM : " << inputBFM << std::endl; - std::cout << "inputConnection : " << inputConnection << std::endl; - std::cout << "stepwidth : " << stepwidth << std::endl; - std::cout << "minConversion : " << minConversion << std::endl; - std::cout << "threshold : " << threshold << std::endl; - std::cout << "feCurve : " << feCurve << std::endl; - } - RandomNumberGenerators rng; - rng.seedAll(); - /////////////////////////////////////////////////////////////////////////////// - ///end options parsing - /////////////////////////////////////////////////////////////////////////////// - //Read in th last Config - typedef LOKI_TYPELIST_3(FeatureMoleculesIOUnsaveCheck, FeatureLabel, FeatureReactiveBonds) Features; - typedef ConfigureSystem Config; - typedef Ingredients Ing; - Ing myIngredients; - - TaskManager taskmanager; - - taskmanager.addUpdater( new UpdaterReadBfmFile(inputBFM,myIngredients, UpdaterReadBfmFile::READ_LAST_CONFIG_SAVE),0); - - //initialize and run - taskmanager.initialize(); - taskmanager.run(1); - taskmanager.cleanup(); - std::cout << "Read in conformation and go on to bring it into equilibrium forces..." < Config2; - typedef Ingredients Ing2; - Ing2 myIngredients2; - - myIngredients2.setBoxX(myIngredients.getBoxX()); - myIngredients2.setBoxY(myIngredients.getBoxY()); - myIngredients2.setBoxZ(myIngredients.getBoxZ()); - myIngredients2.setPeriodicX(myIngredients.isPeriodicX()); - myIngredients2.setPeriodicY(myIngredients.isPeriodicY()); - myIngredients2.setPeriodicZ(myIngredients.isPeriodicZ()); - myIngredients2.modifyMolecules().resize(myIngredients.getMolecules().size()); - myIngredients2.modifyMolecules().setAge(myIngredients.getMolecules().getAge()); - - // myIngredients2.setNumOfChains (myIngredients.getNumOfChains()); - // myIngredients2.setNumOfCrosslinks (myIngredients.getNumOfCrosslinks()); - // myIngredients2.setNumOfMonomersPerChain (myIngredients.getNumOfMonomersPerChain()); - // myIngredients2.setNumOfMonomersPerCrosslink(myIngredients.getNumOfMonomersPerCrosslink()); - // myIngredients2.setFunctionality (myIngredients.getFunctionality()); - - myIngredients2.setNumTendomers (myIngredients.getNumTendomers()); - myIngredients2.setNumCrossLinkers (myIngredients.getNumCrossLinkers()); - myIngredients2.setNumMonomersPerChain (myIngredients.getNumMonomersPerChain()); - myIngredients2.setNumLabelsPerTendomerArm(myIngredients.getNumLabelsPerTendomerArm()); - - for(size_t i = 0; i< myIngredients.getMolecules().size();i++){ - myIngredients2.modifyMolecules()[i].modifyVector3D()=myIngredients.getMolecules()[i].getVector3D(); - myIngredients2.modifyMolecules()[i].setReactive(myIngredients.getMolecules()[i].isReactive()); - myIngredients2.modifyMolecules()[i].setNumMaxLinks(myIngredients.getMolecules()[i].getNumMaxLinks()); - for (size_t j = 0 ; j < myIngredients.getMolecules().getNumLinks(i);j++){ - uint32_t neighbor(myIngredients.getMolecules().getNeighborIdx(i,j)); - if( ! myIngredients2.getMolecules().areConnected(i,neighbor) ) - myIngredients2.modifyMolecules().connect(i,neighbor); - } - } - myIngredients2.synchronize(); - - TaskManager taskmanager2; - //read bonds and positions stepwise - taskmanager2.addUpdater( new UpdaterReadCrosslinkConnectionsTendomer(myIngredients2, inputConnection, stepwidth, minConversion) ); - auto updater = new UpdaterForceBalancedPositionTendomer(myIngredients2, threshold) ; - updater->setFilename(feCurve); - updater->setRelaxationParameter(relaxationParameter); - // auto updater = new UpdaterForceBalancedPosition(myIngredients2, threshold) ; - taskmanager2.addUpdater( updater ); - taskmanager2.addAnalyzer(new AnalyzerEquilbratedPosition(myIngredients2,outputDataPos, outputDataDist)); - //initialize and run - taskmanager2.initialize(); - taskmanager2.run(); - taskmanager2.cleanup(); - - } - catch(std::exception& e){ - std::cerr<<"Error:\n" - < Date: Mon, 31 Jan 2022 10:28:42 +0100 Subject: [PATCH 70/70] add description in README.md --- README.md | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f3dfca7..ea4bc23 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ This project needs the [LeMonADE-library](https://github.com/LeMonADE-project/Le This will run `cmake` and create the `build` directory. Now type in `make` which compiles the executables and runs the test if this option was given. -## Linear chains with cross linkers +## Linear chains with cross-links The main [program](https://github.com/LeMonADE-project/LeMonADE_PhantomModulus/blob/master/projects/ForceEquilibrium.cpp) reads in a .bfm file and a data file. It is expected that the bfm file contains the following flags ``` #!number_of_linear_chains=value @@ -23,12 +23,26 @@ The main [program](https://github.com/LeMonADE-project/LeMonADE_PhantomModulus/b 1-1:1/2 ... ``` -Moreover, it is expected that in the bfm file first all chains and afterwards all crosslinks are given. +Moreover, it is expected that in the bfm file first all chains and afterwards all cross-links are given. The data file should be created during the connection process and needs to contain: ``` Time ChainID MonID1 P1X P1Y P1Z MonID2 P2X P2Y P2Z ``` -where MonID1 and MonID2 are the cross link ID starting at 0. ChainID starts at 0 as well. +where MonID1 and MonID2 are the cross-link ID starting at 0. ChainID starts at 0 as well. For the calculations only the ChainID and MonID1 is needed. The remaining fields are arbitrary for a correct calculation of the positions of the cross links in a force equilibrium. (The format was given from a previous simulation.) + +## Write out parts of the networks +For the force equilibrium only active chains are of interest. +Therefore, there exist two programs extracting the active gel structure from the total system. + +## Tendomer +There are programs specialized on tendomers. They read the tendomer specific tag and can use a +custom force extension relation (e.g. numerical solution of the tendomer) to calculate the forces +between cross-links. + +## Ideal reference +These systems are tendomer specific. A star is created and a monomer along the chain with a distance to the center +according to the tendomer distribution of the number of elastic segments is marked as fixed in space. +In a second system a double star is simulated. \ No newline at end of file