richard-evans / vampire

Atomistic simulator for magnetic materials
GNU General Public License v2.0
122 stars 92 forks source link

Fixed Cuda bugs causing empty exchange list and incorrect results #55

Closed mattoaellis closed 3 years ago

mattoaellis commented 3 years ago

Hi Richard,

I have fixed:

  1. Bug where it would crash when forming the exchange matrix when exchange is zero. Now if there is no non-zeros in the exchange matrix it will skip the initialisation and when computing the field. There is a tolerance parameter in the exchange cuda file that cuts off any exchange values lower than that. At the moment it is 1e-10 Tesla, while for Jij = 11.2e-21 Joules and mu=1.72 muB the values of the matrix will be around 700. Using this unnecessary calculations can be avoided. Before it would cut out the zero exchange but still try to create the lists but they are empty thus crashing.

  2. Bug where it would act incorrectly for large number of spins. For around 100K spins the exchange creation routine was causing overflow of some of the integer values. I have changed these to size_t variables that should be safe against this for large system sizes. I tested around 2M atoms with no issue and results were consistent.

Cheers, Matt