spirit-code / spirit

Atomistic Spin Simulation Framework
http://spirit-code.github.io
MIT License
120 stars 53 forks source link

Calculating topological charge in for loop (Python API) #632

Closed FinnHoller closed 1 year ago

FinnHoller commented 1 year ago

I would like to calculate the topological charge for different spin textures, stored in separate OVF files. With a python script I am iterating over these files, importing them to Spirit and calculating the topological charge as follows:

from spirit import quantities, state, io

ovffiles = ['/path/file1.ovf', '/path/file2.ovf', '/path/file3.ovf']

with state.State('input.cfg') as p_state:
    for ovffile in ovffiles:
        io.image_read(p_state, ovffile)
        Q = quantities.get_topological_charge(p_state)

The topological charge is only being correctly calculated for the first iteration, the subsequent OVF files will always give a Q of 0, even if they contain the same spin texture. What is causing this incorrect calculation of Q?

A possible work-around which I have found, is reading the files with the IO::Read_NonOVF_Spin_Configuration function.

MSallermann commented 1 year ago

Hi Finn, can you provide some more details about the version of Spirit you're using? Which commit and OS? I have, unsuccessfully, tried to reproduce this issue on the current master and develop branch

FinnHoller commented 1 year ago

Hi, turns out I was working with a Spirit binary that was compiled for a different class of CPUs. I have recompiled a binary and now it works without issues.