/* mmut/mmut_nma.h: CCP4MG Molecular Graphics Program Copyright (C) 2001-2008 University of York, CCLRC This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3, modified in accordance with the provisions of the license to address the requirements of UK law. You should have received a copy of the modified GNU Lesser General Public License along with this library. If not, copies may be downloaded from http://www.ccp4.ac.uk/ccp4license.php This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. */ #include "mmut_nma.h" #include #include #include #include #include #include #include #ifndef M_PI #define M_PI 3.141592653589793238462643 #endif #define kBA 1.3806503e-03 // Boltzmann constant scaled for angstroms. #define TEMP 298.155 NormalModeAnalysis::NormalModeAnalysis(const std::vector &carts, const int type, const double cutoff){ if(type==MMUT_ANM){ if(cutoff<0.0) NMA_ANM(carts,13.0); else NMA_ANM(carts,cutoff); _type = MMUT_ANM; }else{ if(cutoff<0.0) NMA_GNM(carts,7.0); else NMA_GNM(carts,cutoff); _type = MMUT_GNM; } } /* NormalModeAnalysis::NormalModeAnalysis(const std::vector &carts, const std::string &type, const double cutoff){ if(type=="ANM"){ if(cutoff<0.0) NMA_ANM(carts,13.0); else NMA_ANM(carts,cutoff); _type = MMUT_ANM; }else{ if(cutoff<0.0) NMA_GNM(carts,7.0); else NMA_GNM(carts,cutoff); _type = MMUT_GNM; } } */ void NormalModeAnalysis::NMA_ANM(const std::vector &carts, const double cutoff){ /* Generate the Kirchoff matrix */ matrix k(carts.size(),carts.size()); for(unsigned i=0;i &carts, const double cutoff){ /* Generate the Kirchoff matrix for isotropic Gaussian network model */ matrix a(carts.size(),carts.size()); for(unsigned i=0;i NormalModeAnalysis::GetBValues() const { // These B-values have to be divided by the force constant. // Unfortunately we do not know that, so these values need // to be scaled to agree with the experimental B-factors. // This isn't quite self-defeating, we can now calculate the // force constant and use it for other purposes. std::vector bvalues; if(_type==MMUT_ANM){ std::cerr << "Warning, B-value calculation for anisotropic method not yet implemented!\n"; return bvalues; } matrix my_hinv = GetDiagonalInverseHessian(); //std::cout << "Inverse Hessian\n"; //std::cout << my_hinv << "\n"; double prefactor=8.0*M_PI*M_PI*kBA*TEMP; for(unsigned i=0;i > NormalModeAnalysis::GetModeShapes(const double gammainv) const { // Almost certainly only correct for GNM at the moment. // Returns N-1 (or N-6 for ANM) vectors of N-values describing mobility of nodes. // gammainv can be calculated by comparing experimental with calculated B-values. std::vector > mode_shapes; matrix eigenvecs = eigen[0]; matrix eigenvals = eigen[1]; int start = 1; if(GetType()==MMUT_ANM){ start = 6; } double prefactor=8.0*M_PI*M_PI*kBA*TEMP*gammainv; for(unsigned i=start;i(eigenvecs.get_rows())); if(fabs(eigenvals(i,0))>1e-7){ double einv = 1.0/eigenvals(i,0); for(unsigned ii=0;ii1e-7){ double einv = 1.0/eigenvals(i,0); for(unsigned ii=0;ii1e-7){ double einv = 1.0/eigenvals(i,0); matrix u(eigenvecs.get_rows(),1); for(unsigned j=0;j > NormalModeAnalysis::GetDisplacements(const int nsteps) const{ std::vector > displacements; matrix evecs = eigen[0]; matrix evals = eigen[1]; if(_type==MMUT_GNM){ std::cerr << "Cannot compute displacements for Gaussian Network Model, try Anisotropic method\n"; } displacements = std::vector > (evecs.get_columns()-6); for(unsigned k=6;k