当前位置: 首页>>代码示例>>C++>>正文


C++ Cell::addAtom方法代码示例

本文整理汇总了C++中Cell::addAtom方法的典型用法代码示例。如果您正苦于以下问题:C++ Cell::addAtom方法的具体用法?C++ Cell::addAtom怎么用?C++ Cell::addAtom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cell的用法示例。


在下文中一共展示了Cell::addAtom方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{
    Cell cell;
    cell.setBasisVectors(1.0,10.0,10.0,90.0,90.0,90.0);
    
    Sublattice spin0;
    string name0 = "Spin0";
    spin0.setName(name0);
    spin0.setType("NONE");
    spin0.setMoment(1.0,0.0,0.0);
    cell.addSublattice(spin0);
    cell.addAtom(name0,0.0,0.0,0.0);
    
    Sublattice spin1;
    string name1 = "Spin1";
    spin1.setName(name1);
    spin1.setType("NONE");
    spin1.setMoment(1.0,M_PI,0.0);
    cell.addSublattice(spin1);
    cell.addAtom(name1,0.5,0.0,0.0);
    
    SpinWaveBuilder builder(cell);
    
    InteractionFactory interactions;
    
    Vector3 xhat(1.0,0.0,0.0);
    builder.addInteraction(interactions.getExchange("J",-1.0,name0,name1,0.4,0.6));
    builder.addInteraction(interactions.getAnisotropy("D",0.1,xhat,name0));
    builder.addInteraction(interactions.getAnisotropy("D",0.1,xhat,name1));
    SpinWave SW = builder.createElement();
    
    PointsAlongLine Line;
    Line.setFirstPoint(0.0,0.0,0.0);
    Line.setFinalPoint(0.0,0.0,3.0*2.0*M_PI);
    Line.setNumberPoints(201);
    ThreeVectors<double> kPoints = Line.getPoints();
    
    Energies energies(0.2, 3.0, 201);
    
    OneDimensionalFactory factory;
    auto gauss = factory.getGaussian(0.15,1.0e-1);
    
    unique_ptr<SpinWavePlot> res(new EnergyResolutionFunction(move(gauss), SW,energies));
    unique_ptr<SpinWavePlot> cut(new IntegrateThetaPhi(move(res),1.0e-1));

    TwoDimensionalCut twodimcut;
    twodimcut.setFilename("AFMPowderAverage");
    twodimcut.setPlotObject(move(cut));
    twodimcut.setPoints(kPoints);
    twodimcut.save();
    return 0;
}
开发者ID:rockspore,项目名称:SHUG2015Tutorial,代码行数:52,代码来源:PowderAverage.cpp

示例2: createMnBiCell

Cell createMnBiCell()
{
    double SA = 2.0;
    double theta = M_PI/2.0;
    
    Cell cell;
    cell.setBasisVectors(4.2827,4.2827,6.1103,90.0,90.0,120.0);
    
    Sublattice Spin0;
    std::string name = "Spin0";
    Spin0.setName(name);
    Spin0.setType("MN2");
    Spin0.setMoment(SA,theta,0.0);
    cell.addSublattice(Spin0);
    cell.addAtom(name,0.0,0.0,0.0);
    cell.addAtom(name,0.0,0.0,0.5);
    
    return cell;
}
开发者ID:rosswhitfield,项目名称:SpinWaveGenie,代码行数:19,代码来源:NeighborsTest.cpp

示例3: main

int main()
{
    
    double gamma,eta,J,B;
    
    gamma = -2.0;
    eta = -2.0;
    J = 1.0;
    B = 8.0;
    
    double theta = M_PI_2;
    theta = acos(-B/(4.0*gamma));
    cout << "Theta = " << theta << endl;
    
    Cell cell;
    cell.setBasisVectors(1.0,2.0,10.0,90.0,90.0,90.0);
    
    Sublattice a1;
    string name1 = "a1";
    a1.setName(name1);
    a1.setType("NONE");
    a1.setMoment(1.0,theta,0.0);
    cell.addSublattice(a1);
    cell.addAtom(name1,0.0,0.0,0.0);
    
    Sublattice b1;
    string name2 = "b1";
    b1.setName(name2);
    b1.setType("NONE");
    b1.setMoment(1.0,theta,M_PI);
    cell.addSublattice(b1);
    cell.addAtom(name2,0.0,0.5,0.0);

    SpinWaveBuilder builder(cell);
    
    InteractionFactory interactions;
    
    builder.addInteraction(interactions.getExchange("J",J,name1,name1,0.9,1.1));
    builder.addInteraction(interactions.getExchange("metaJ",-1.0*eta*J,name2,name2,0.9,1.1));
    builder.addInteraction(interactions.getExchange("gammaJ",gamma*J,name1,name2,0.9,1.1));
    
    Vector3 zhat(0.0,0.0,1.0);
    builder.addInteraction(interactions.getMagneticField("B",B,zhat,name1));
    builder.addInteraction(interactions.getMagneticField("B",B,zhat,name2));

    SpinWave test = builder.createElement();
    
    PointsAlongLine Line;
    Line.setFirstPoint(0.0,1.0,0.0);
    Line.setFinalPoint(0.0,2.0,0.0);
    Line.setNumberPoints(11);
    ThreeVectors<double> kPoints = Line.getPoints();
    
    SpinWaveDispersion dispersion;
    dispersion.setFilename("AFMChain.txt");
    dispersion.setGenie(test);
    dispersion.setPoints(kPoints);
    
    dispersion.save();
    
    /*double kx(0.0),ky(0.0);
    double R2Kp = (eta-1.0)*(cos(kx)-1.0)+2.0*gamma*(-1.0+cos(ky));
    double R2Km = (eta-1.0)*(cos(kx)-1.0)+2.0*gamma*(-1.0-cos(ky));
    double term = (eta+1.0)*(cos(kx)-1.0);
    cout << sqrt(R2Kp*R2Km) +term << " " << sqrt(R2Kp*R2Km) +term << endl;
    cout << sqrt(R2Kp/R2Km) << " " << sqrt(R2Kp/R2Km) << endl;
    
    kx = M_PI;
    R2Kp = (eta-1.0)*(cos(kx)-1.0)+2.0*gamma*(-1.0+cos(ky));
    R2Km = (eta-1.0)*(cos(kx)-1.0)+2.0*gamma*(-1.0-cos(ky));
    term = (eta+1.0)*(cos(kx)-1.0);
    cout << sqrt(R2Kp*R2Km) +term << " " << sqrt(R2Kp*R2Km) -term << endl;
    cout << sqrt(R2Kp/R2Km) << " " << sqrt(R2Kp/R2Km) << endl;

    kx = 2.0*M_PI;
    R2Kp = (eta-1.0)*(cos(kx)-1.0)+2.0*gamma*(-1.0+cos(ky));
    R2Km = (eta-1.0)*(cos(kx)-1.0)+2.0*gamma*(-1.0-cos(ky));
    term = (eta+1.0)*(cos(kx)-1.0);
    cout << sqrt(R2Kp*R2Km) +term << " " << sqrt(R2Kp*R2Km) +term << endl;
    cout << sqrt(R2Kp/R2Km) << " " << sqrt(R2Kp/R2Km) << endl;
*/
    return 0;
}
开发者ID:rosswhitfield,项目名称:SpinWaveGenie,代码行数:83,代码来源:SC2Dispersion.cpp

示例4: newDocument

    void newDocument() {
        mask.clear();
        etchingAction->setEnabled(true);
        maskAction->setEnabled(true);
        saveAct->setEnabled(true);

        QTime t;
        z_min = 0;
        int const xMax = SIZE_X;
        int const yMax = SIZE_Y;
        int const zMax = SIZE_Z;
        z_center = z_min + (zMax - 2 - z_min) / 2;

        cell = Cell(h, k, l);
        Xsize = cell.getXSize();
        Ysize = cell.getYSize();
        Zsize = cell.getZSize();

        Vx = cell.getVx();
        Vy = cell.getVy();
        Vz = cell.getVz();

        cell.optimize();

        auto const numberOfAtomInCell =
            static_cast<unsigned int>(cell.size());
        neighbors = cell.findNeighbors(Xsize, Ysize, Zsize);

        surfaceXYZ.reset(new Surface3D(cell));
        surfaceXYZ->clear();
        surfaceXYZ->reserve(SIZE_Z);
        for (int z = 0; z < SIZE_Z; ++z) {
            Surface2D surfaceXY;
            surfaceXY.reserve(SIZE_Y);
            for (int y = 0; y < SIZE_Y; ++y) {
                Surface1D surfaceX;
                surfaceX.reserve(SIZE_X);
                for (int x = 0; x < SIZE_X; ++x) {
                    Cell cell;
                    for (unsigned char a = 0; a < numberOfAtomInCell; ++a) {
                        Neighbors neighbs;
                        char numberNeighbs = 0; // number of the first neighbors
                        for (int nb = 0; nb < 4; ++nb) {
                            auto& neighborsANb = neighbors[a][nb];
                            if (x + neighborsANb.x >= 0
                                && y + neighborsANb.y >= 0
                                && z + neighborsANb.z >= 0
                                && x + neighborsANb.x < xMax
                                && y + neighborsANb.y < yMax
                                && z + neighborsANb.z < zMax + 1) {
                                ++numberNeighbs;
                                AtomType neighb = {x + neighborsANb.x, y + neighborsANb.y,
                                                   z + neighborsANb.z, neighborsANb.type,
                                                   false};
                                neighbs.push_back(neighb);
                            }
                        }

                        AtomInfo atom;
                        atom.neighbors = neighbs;
                        atom.firstNeighborsCount = numberNeighbs;
                        atom.deleted = numberNeighbs == 0;
                        // TODO: atom.type =
                        cell.addAtom(atom);
                    }
                    surfaceX.push_back(cell);
                }
                surfaceXY.push_back(surfaceX);
            }
            surfaceXYZ->push_back(surfaceXY);
        }
        surfaceXYZ->rebuildSurfaceAtoms();
        drawResult();
    }
开发者ID:Hexta,项目名称:GRES,代码行数:74,代码来源:MainWindow.cpp

示例5: main

int main()
{
    std::array<double,4> BValues{{0.0,4.0,8.0,10.0}};
    for (auto B:BValues)
    {
      double gamma,eta,J;
      gamma = -2.0;
      eta = -2.0;
      J = 1.0;
    
      double theta = M_PI_2;
      theta = acos(-B/(4.0*gamma));
      if (theta != theta) //check for nan
        theta = 0.0;
      cout << "Theta = " << theta << endl;
    
      Cell cell;
      cell.setBasisVectors(1.0,2.0,10.0,90.0,90.0,90.0);
    
      Sublattice a1;
      string name1 = "a1";
      a1.setName(name1);
      a1.setType("NONE");
      a1.setMoment(1.0,theta,0.0);
      cell.addSublattice(a1);
      cell.addAtom(name1,0.0,0.0,0.0);
    
      Sublattice b1;
      string name2 = "b1";
      b1.setName(name2);
      b1.setType("NONE");
      b1.setMoment(1.0,theta,M_PI);
      cell.addSublattice(b1);
      cell.addAtom(name2,0.0,0.5,0.0);

      SpinWaveBuilder builder(cell);
    
      InteractionFactory interactions;
    
      builder.addInteraction(interactions.getExchange("J",J,name1,name1,0.9,1.1));
      builder.addInteraction(interactions.getExchange("metaJ",-1.0*eta*J,name2,name2,0.9,1.1));
      builder.addInteraction(interactions.getExchange("gammaJ",gamma*J,name1,name2,0.9,1.1));
    
      Vector3 zhat(0.0,0.0,1.0);
      builder.addInteraction(interactions.getMagneticField("B",B,zhat,name1));
      builder.addInteraction(interactions.getMagneticField("B",B,zhat,name2));

      SpinWave test = builder.createElement();
    
      PointsAlongLine Line;
      Line.setFirstPoint(0.5,0.0,0.0);
      Line.setFinalPoint(0.0,0.0,0.0);
      Line.setNumberPoints(101);
      ThreeVectors<double> kPoints = Line.getPoints();
    
      Line.setFirstPoint(0.0,0.0,0.0);
      Line.setFinalPoint(0.0,1.0,0.0);
      Line.setNumberPoints(101);
      ThreeVectors<double> kPoints2 = Line.getPoints();
    
      SpinWaveDispersion dispersion;
      dispersion.setFilename("SC2Chain_"+std::to_string(static_cast<int>(B))+".txt");
      dispersion.setGenie(test);
      dispersion.setPoints(kPoints);
      dispersion.setPoints(kPoints2);
      dispersion.save();
    
    }
    return 0;
}
开发者ID:rockspore,项目名称:SHUG2015Tutorial,代码行数:70,代码来源:SC2Dispersion.cpp

示例6: createModel

SpinWaveGenie::SpinWave createModel()
{
    // Cell object stores the basis vectors and Sublattice objects
    Cell cell;
    // set a,b,c,alpha,beta,gamma in units of Angstroms, Degrees
    cell.setBasisVectors(5.4,5.4,7.63675323681,90.0,90.0,90.0);
    
    // parameters used for calculating angles
    double delta = 0.00516;
    double phi = 0.0032;
    
    Sublattice Fe1;
    //each Sublattice contains:
    //  a unique name,
    std::string name1 = "Fe1";
    Fe1.setName(name1);
    //  type (used to calculate the magnetic form factor)
    Fe1.setType("FE3");
    //  magnetic moment (magnitude,theta (radians), phi (radians))
    Fe1.setMoment(2.5,M_PI/2.0-delta,M_PI+phi);
    //add sublattice to Cell cell.
    cell.addSublattice(Fe1);
    // add atom to sublattice name1 at position (0,0.5,0) in reduced lattice units.
    cell.addAtom(name1,0.0,0.5,0.0);

    //repeat for Sublattice Fe2,Fe3 and Fe4
    Sublattice Fe2;
    std::string name2 = "Fe2";
    Fe2.setName(name2);
    Fe2.setType("FE3");
    Fe2.setMoment(2.5,M_PI/2.0-delta,phi);
    cell.addSublattice(Fe2);
    cell.addAtom(name2,0.0,0.5,0.5);

    Sublattice Fe3;
    std::string name3 = "Fe3";
    Fe3.setName(name3);
    Fe3.setType("FE3");
    Fe3.setMoment(2.5,M_PI/2.0-delta,M_PI-phi);
    cell.addSublattice(Fe3);
    cell.addAtom(name3,0.5,0.0,0.5);

    Sublattice Fe4;
    std::string name4 = "Fe4";
    Fe4.setName(name4);
    Fe4.setType("FE3");
    Fe4.setMoment(2.5,M_PI/2.0-delta,2.0*M_PI-phi);
    cell.addSublattice(Fe4);
    cell.addAtom(name4,0.5,0.0,0.0);
    
    // add Cell cell to the builder
    SpinWaveBuilder builder(cell);
    
    // Factory for defining interactions.
    InteractionFactory interactions;
   
    Vector3 xhat(1.0,0.0,0.0);
    // get anisotropy interaction named "Ka" with value "-0.0055" in the "xhat" direction on sublattice name1.
    // pass this interaction to the builder.
    // repeat for interactions name2,name3,name4
    builder.addInteraction(interactions.getAnisotropy("Ka",-0.0055,xhat,name1));
    builder.addInteraction(interactions.getAnisotropy("Ka",-0.0055,xhat,name2));
    builder.addInteraction(interactions.getAnisotropy("Ka",-0.0055,xhat,name3));
    builder.addInteraction(interactions.getAnisotropy("Ka",-0.0055,xhat,name4));

    Vector3 zhat(0.0,0.0,1.0);
    // get anisotropy interaction named "Kc" with value "-0.00305" in the "zhat" direction on sublattice name1.
    // pass this interaction to the builder.
    // repeat for interactions name2,name3,name4
    builder.addInteraction(interactions.getAnisotropy("Kc",-0.00305,zhat,name1));
    builder.addInteraction(interactions.getAnisotropy("Kc",-0.00305,zhat,name2));
    builder.addInteraction(interactions.getAnisotropy("Kc",-0.00305,zhat,name3));
    builder.addInteraction(interactions.getAnisotropy("Kc",-0.00305,zhat,name4));

    // get exchange interaction named "J1" with value "-4.77" between sublattices name1 and name2.
    // limit atoms to those between 3.8 and 4.3 angstroms.
    // pass this interaction to the builder.
    // repeat for interactions between name1 and name4, name2 and name3, name3 and name4.
    builder.addInteraction(interactions.getExchange("J1",-4.77,name1,name2,3.8,4.3));
    builder.addInteraction(interactions.getExchange("J1",-4.77,name1,name4,3.8,4.3));
    builder.addInteraction(interactions.getExchange("J1",-4.77,name3,name2,3.8,4.3));
    builder.addInteraction(interactions.getExchange("J1",-4.77,name3,name4,3.8,4.3));
    
    // get exchange interaction named "J2" with value "-0.21" between sublattices name1 and name1.
    // limit atoms to those between 5.3 and 5.5 angstroms.
    // pass this interaction to the builder.
    // repeat for interactions between other pairs.
    builder.addInteraction(interactions.getExchange("J2",-0.21,name1,name1,5.3,5.5));
    builder.addInteraction(interactions.getExchange("J2",-0.21,name2,name2,5.3,5.5));
    builder.addInteraction(interactions.getExchange("J2",-0.21,name3,name3,5.3,5.5));
    builder.addInteraction(interactions.getExchange("J2",-0.21,name4,name4,5.3,5.5));
    builder.addInteraction(interactions.getExchange("J2",-0.21,name1,name3,5.3,5.5));
    builder.addInteraction(interactions.getExchange("J2",-0.21,name2,name4,5.3,5.5));

    Vector3 yhat(0.0,1.0,0.0);
    // get Dzyaloshinskii-Moriya interaction named "D1" with value "-0.074" in the yhat direction between sublattices name4 and name1.
    // limit atoms to those between 3.8 and 4.3 angstroms.
    // pass this interaction to the builder.
    // repeat for interactions between other pairs.
    builder.addInteraction(interactions.getDzyaloshinskiiMoriya("D1",-0.074,yhat,name4,name1,3.8,4.3));
//.........这里部分代码省略.........
开发者ID:rockspore,项目名称:SHUG2015Tutorial,代码行数:101,代码来源:CommonFunctions.cpp


注:本文中的Cell::addAtom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。