Specific spin assignment

997 views
Skip to first unread message

Bibek Tiwari

unread,
Jan 13, 2021, 12:15:00 AM1/13/21
to Vampire Users
Suppose i have say  50 or100 atoms. is it possible to assign each atoms , spin direction of our choice in Vampire?

Richard Evans

unread,
Jan 13, 2021, 4:46:45 AM1/13/21
to Vampire Users
Hi,

Yes - up to 100 different materials are supported, so you can set them that way if you wish - eg each atom is a unique material, material[1]:initial-spin-direction = 1,0,0 etc. As that is quite specific though, it may be more efficient to do that in the source code. For example, in the program time series you could directly modify the atoms::x_spin_array etc to write in whatever directions you wanted before running the program.

All the best,

Richard

kkhu...@gmail.com

unread,
Jan 14, 2021, 3:57:16 PM1/14/21
to Vampire Users
Hello Richard,

I'm also very interested in this question.

Suppose I have a even larger system with >10000 atoms (besides, structure input from .ucf file), and want the initial spin configuration customized by myself. How should I do? Could you please give some more information about coding on atoms::x_spin_array?

Thank you very much!

Kai
01/14/2021

Richard Evans

unread,
Jan 14, 2021, 4:16:57 PM1/14/21
to Vampire Users
Hi Kai,

So you need to learn some basic C++, but in the program time series, before the main time while-loop you could add:

// set up a new random number sequence (flat distribution 0-1)
MTRand myrng;

// loop over all atoms
for(int i=0; i<atoms::num_atoms; i++){

// set random spin positions in x and y (actually biased towards xy direction due to large phase space before normalisation)
double sx = 2.0*myrng() - 1.0;
double sy = 2.0*myrng() - 1.0;
double sz = 0.0;

// calculate spin length for normalisation so |S| = 1
double inorm = 1.0 / sqrt(sx*sx + sy*sy + sz*sz);

// set up normalised spin components
atoms::x_spin_array[i] = sx*inorm;
atoms::y_spin_array[i] = sy*inorm;
atoms::z_spin_array[i] = sz*inorm;

}

which would set semi-random spin-directions in the plane, for example. We could in principle set this up as a feature, but it needs global atom addressing to work properly in parallel - but these direct modifications to the source code are not too complicated and are quite easy to do. You can Aldo do other things like making the spins depend on x, eg a vortex state. Actually, thinking about this, this could be an interesting thing to do anyway vortex states, domain walls, checkerboard, skyrmions etc - I'll add it to the future feature list!

All the best,

Richard 

Gabriel Chaves

unread,
Nov 23, 2022, 2:22:21 PM11/23/22
to Vampire Users
I just wrote the following segment to load a specific configuration from a previous file. I hope somebody finds it useful.


    long int numberofatoms,i=0;
    double sx,sy,sz;
    std::string myText;
    std::ifstream initialspinfile("spins-00000000.ini");
    if(!initialspinfile){
        std::cerr << "File could not be opened.\n";
        exit(EXIT_FAILURE);
    } else {
        initialspinfile >> numberofatoms;
        while (initialspinfile >> sx >> sy >> sz) {
            atoms::x_spin_array[i] = sx;
            atoms::y_spin_array[i] = sy;
            atoms::z_spin_array[i] = sz;
            i++;
        }
        initialspinfile.close();
    }
    stats::mag_m();
    vout::data();

Gabriel Chaves

unread,
Nov 24, 2022, 8:55:57 AM11/24/22
to Vampire Users
A small update below, 
For randomized alloys it may be also necessary to load the material type, so the script below also imports the material type from the atom-coords file.
We need to check with the creators if this is enough to have good calculations of energy terms.
Best,
Gabriel

----------------------------------
    long int numberofatoms,i=0;
    double sx,sy,sz,atomiclayer,materialtype;

    std::string myText;
    std::ifstream initialspinfile("spins-00000000.ini");
    //Load spin data
    if(!initialspinfile){
        std::cerr << "Spin direction file could not be opened.\n";

        exit(EXIT_FAILURE);
    } else {
        initialspinfile >> numberofatoms;
        while (initialspinfile >> sx >> sy >> sz) {
            atoms::x_spin_array[i] = sx;
            atoms::y_spin_array[i] = sy;
            atoms::z_spin_array[i] = sz;
            i++;
        }
        initialspinfile.close();
    }
    //Copy materials type structure.
    initialspinfile.open("atoms-coords.ini");
    i=0;
    if(!initialspinfile){
        std::cerr << "Atom definition file could not be opened.\n";
        exit(EXIT_FAILURE);
    } else {
        initialspinfile >> numberofatoms;
        while (initialspinfile >> materialtype >> atomiclayer >> sx >> sy >> sz) {
            atoms::type_array[i] = materialtype;

            i++;
        }
        initialspinfile.close();
    }
   
    stats::mag_m();
    vout::data();

kkhu...@gmail.com

unread,
Jun 28, 2023, 1:48:20 PM6/28/23
to Vampire Users
Thank you Gabriel!

But in which specific code file should I place this code?

Thanks a lot,
Kai

Message has been deleted
Message has been deleted

Gabriel Chaves

unread,
Jul 7, 2023, 4:38:38 AM7/7/23
to kkhu...@gmail.com, Vampire Users
Hi Kai,

These are the files I needed to modify to get that task done. I also created a global variable to allow me to turn off the precession, since I am mostly interested in the energy landscape.

Locations for the files:
"sim.hpp" should be placed in folder "hdr"
"LLGHeun.cpp" should be placed in folder "/src/simulate/"
"match.cpp" should be placed 

in folder 
"/src/vio/"What they do:"sim.hpp" defines the variable to enable precession (previously always true).
"LLGHeun.cpp" does the time evolution, now with or without precession.
"match.cpp" interprets the input file.

I suggest you create a separate folder for your modified version of vampire. And do "make" to rebuild it before using it. Do not overwrite your current installation.

However, I have to tell you this: my solution is incomplete because I do not know where other important data gets stored and how to retrieve it. Take, for instance, what I am trying to get done. I want to study a random alloy where the uniaxial anysotropic axis points randomly. It turns out that saving the current magnetization is not enough to restore the state of the system. I need to also set all other material parameters to the same values (e.g. the directions of anisotropy vectors). I am in the process of finding where they are stored in the code and at which point of the algorithm they should be loaded into memory.

At this point Richard Evans could help us a great deal by telling us where and when these variables are stored. Thank you in advance.

Best,

Gabriel

--
You received this message because you are subscribed to the Google Groups "Vampire Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vampire-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vampire-users/4e20c510-a2cd-4ebe-b756-74d8f658c6c5n%40googlegroups.com.


--
Gabriel D. Chaves-O'Flynn
Senior Lecturer
Institute of Molecular Physics
Polish Academy of Sciences

sim.hpp
LLGHeun.cpp
match.cpp
Reply all
Reply to author
Forward
0 new messages