コード例 #1
0
ファイル: AtomLayer.C プロジェクト: nutjunkie/IQmol
Atom::Atom(int Z) : Primitive("Atom"), m_charge(0.0), m_spin(0.0), m_nmr(0.0),
   m_smallerHydrogens(true), m_haveNmrShift(false), m_reorderIndex(0), 
   m_hybridization(0)
{
   setAtomicNumber(Z);
   if (!s_vibrationColorInitialized) {
      setVibrationVectorColor(Preferences::VibrationVectorColor());
   }

   // We don't allow changes to the valency at the moment as it seems to be unstable
   // Need to check the OpenBabel code again.
   return;
   QActionGroup* hybrids(new QActionGroup(this));
   QStringList labels;
   labels << "sp" << "sp2" << "sp3" << "Square Planar" 
           << "Trigonal Bipyramid" << "Octahedral";

   for (int i = 0; i < labels.size() ; ++i) {
       QAction* action(newAction(labels[i]));
       action->setData(i+1);
       action->setCheckable(true);
       action->setChecked(false);
       hybrids->addAction(action);
       connect(action, SIGNAL(triggered()), this, SLOT(updateHybridization()));
   }
}
コード例 #2
0
ファイル: main.cpp プロジェクト: SteffenPL/PaSi
    bool loadFromFile( const std::string& filename )
    {
        setAtomicNumber("X", -1);

        std::ifstream file( filename );

        enum EParameterType{
            EUnknown,
            EMass,
            EBonds,
            EAngles,
            EDihedrals,
            EImproper,
            ENonBonded
        } state;

        state = EUnknown;

        std::string line;
        std::string value;

        while( file.good() )
        {
            std::getline( file , line );

            auto it = line.find('!');
            if( it != std::string::npos )
                line = line.substr( 0 , --it );

            std::stringstream ss;
            ss << line;
            ss >> value;


            bool newCategory = true;

            // there are different cases

            // is the current value a new category?

            if( value == "BONDS" )
                state = EBonds;
            else if( value == "ANGLES" )
                state = EAngles;
            else if( value == "DIHEDRALS" )
                state == EDihedrals;
            else if( value == "IMPROPER" )
                state = EImproper;
            else if( value == "NONBONDED")
                state = ENonBonded;
            else
                newCategory = false;

            // ok, if the current line is not the title of a new category,
            // then we exect it to contain parameters or a comment

            if( !newCategory )
            {
                switch(state)
                {
                    case EBonds:
                    {
                        std::string a1,a2;
                        double kb,b0;

                        a1 = value;
                        ss >> a2 >> kb >> b0;

                        Eigen::Vector2i v;
                        v[0] = atomID(a1);
                        v[1] = atomID(a2);

                        m_kb[v] = kb;
                        m_b0[v] = b0;
                    }
                    break;


                    case EAngles:
                    {
                        std::string a1,a2,a3;
                        double k_theta,theta0;

                        a1 = value;
                        ss >> a2 >> a3 >> k_theta >> theta0;

                        Eigen::Vector3i v;
                        v[0] = atomID(a1);
                        v[1] = atomID(a2);
                        v[2] = atomID(a3);

                        m_k_theta[v] = k_theta;
                        m_theta0[v] = theta0;
                    }
                    break;


                    case EDihedrals:
                    {
                        std::string a1,a2,a3,a4;
                        double k_chi,delta;
                        int n;

                        a1 = value;
                        ss >> a2 >> a3 >> a4 >> k_chi >> n >> delta;

                        Eigen::Vector4i v;
                        v[0] = atomID(a1);
                        v[1] = atomID(a2);
                        v[2] = atomID(a3);
                        v[3] = atomID(a4);

                        m_k_chi[v] = k_chi;
                        m_n[v] = n;
                        m_delta[v] = delta;
                    }
                    break;


                    case EImproper:
                    {
                        std::string a1,a2,a3,a4;
                        double k_psi,psi0;

                        a1 = value;
                        ss >> a2 >> a3 >> a4 >> k_psi >> psi0;

                        Eigen::Vector4i v;
                        v[0] = atomID(a1);
                        v[1] = atomID(a2);
                        v[2] = atomID(a3);
                        v[3] = atomID(a4);

                        m_k_psi[v] = k_psi;
                        m_psi0[v] = psi0;
                    }
                    break;

                    case ENonBonded:
                    {
                        std::string a1;
                        double epsilon,r_min_half;

                        a1 = value;
                        ss >> epsilon >> r_min_half;

                        int v = atomID(a1);

                        m_epsilon[v] = epsilon;
                        m_r_min_half[v] = r_min_half;
                    }
                    break;

                    case EMass:
                    {
                        std::string a1;
                        double mass;

                        a1 = value;
                        ss >> mass;

                        int v = atomID(a1);

                        m_mass[v] = mass;
                    }
                    break;


                    default: // do nothing
                    break;
                }
            }
        }


        return true;
    }