Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: spirit-code/spirit
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d06f4af87cac5ac611f3dbf19a4bfe61b22c9118
Choose a base ref
..
head repository: spirit-code/spirit
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 218b5f5196614eb73c4db7601b1f71956359afef
Choose a head ref
14 changes: 14 additions & 0 deletions core/docs/c-api/Quantities.md
Original file line number Diff line number Diff line change
@@ -37,3 +37,17 @@ void Quantity_Get_Grad_Force_MinimumMode(State * state, float * gradient, float
Minimum mode following information
### Quantity_Get_HTST_Prefactor
```C
float Quantity_Get_HTST_Prefactor(State * state, int idx_image_minimum, int idx_image_sp, int idx_chain=-1)
```

HTST Prefactor for transition from minimum to saddle point.

Note that the method assumes you gave it correct images, where the
gradient is zero and which correspond to a minimum and a saddle point
respectively.

9 changes: 9 additions & 0 deletions core/include/Spirit/Quantities.h
Original file line number Diff line number Diff line change
@@ -22,4 +22,13 @@ PREFIX float Quantity_Get_Topological_Charge(State * state, int idx_image=-1, in
// Minimum mode following information
PREFIX void Quantity_Get_Grad_Force_MinimumMode(State * state, float * gradient, float * eval, float * mode, float * forces, int idx_image=-1, int idx_chain=-1);

/*
HTST Prefactor for transition from minimum to saddle point.
Note that the method assumes you gave it correct images, where the
gradient is zero and which correspond to a minimum and a saddle point
respectively.
*/
PREFIX float Quantity_Get_HTST_Prefactor(State * state, int idx_image_minimum, int idx_image_sp, int idx_chain=-1);

#endif
1 change: 1 addition & 0 deletions core/include/engine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ set(HEADER_SPIRIT_ENGINE
${CMAKE_CURRENT_SOURCE_DIR}/Hamiltonian_Heisenberg.hpp
${CMAKE_CURRENT_SOURCE_DIR}/Hamiltonian_Gaussian.hpp
${CMAKE_CURRENT_SOURCE_DIR}/Eigenmodes.hpp
${CMAKE_CURRENT_SOURCE_DIR}/HTST.hpp
${CMAKE_CURRENT_SOURCE_DIR}/Solver_SIB.hpp
${CMAKE_CURRENT_SOURCE_DIR}/Solver_Heun.hpp
${CMAKE_CURRENT_SOURCE_DIR}/Solver_Depondt.hpp
34 changes: 34 additions & 0 deletions core/include/engine/HTST.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#pragma once
#ifndef HTST_H
#define HTST_H

#include "Spirit_Defines.h"
#include <data/Spin_System.hpp>
#include <data/Spin_System_Chain.hpp>
#include <engine/Vectormath_Defines.hpp>

namespace Engine
{
namespace HTST
{
// Note the two images should correspond to one minimum and one saddle point
void Calculate_Prefactor(Data::HTST_Info & htst_info);

// Calculate the 'a' component of the prefactor
void Calculate_Perpendicular_Velocity(const vectorfield & spins, const scalarfield & mu_s, const MatrixX & hessian,
const MatrixX & basis, const MatrixX & eigenbasis, VectorX & a);

// Calculate the Velocity matrix
void Calculate_Dynamical_Matrix(const vectorfield & spins, const scalarfield & mu_s, const MatrixX & hessian, MatrixX & velocity);

// Calculate the zero volume of a spin system
scalar Calculate_Zero_Volume(const std::shared_ptr<Data::Spin_System> system);

// Generates the geodesic Hessian in 2N-representation and calculates it's eigenvalues and eigenvectors
void Geodesic_Eigen_Decomposition(const vectorfield & image, const vectorfield & gradient, const MatrixX & hessian,
MatrixX & hessian_geodesic_3N, MatrixX & hessian_geodesic_2N, VectorX & eigenvalues, MatrixX & eigenvectors);
};
}


#endif
8 changes: 8 additions & 0 deletions core/python/spirit/quantities.py
Original file line number Diff line number Diff line change
@@ -27,6 +27,14 @@ def get_magnetization(p_state, idx_image=-1, idx_chain=-1):
return [float(i) for i in magnetization]


_Get_HTST_Prefactor = _spirit.Quantity_Get_HTST_Prefactor
_Get_HTST_Prefactor.argtypes = [ctypes.c_void_p, ctypes.c_int, ctypes.c_int, ctypes.c_int]
_Get_HTST_Prefactor.restype = ctypes.c_float
def get_htst_prefactor(p_state, idx_image_minimum, idx_image_sp, idx_chain=-1):
"""Calculates and returns the HTST rate prefactor."""
return _Get_HTST_Prefactor(p_state, idx_image_minimum, idx_image_sp, idx_chain)


### Temporary info function for MMF
_Get_MinimumMode = _spirit.Quantity_Get_Grad_Force_MinimumMode
_Get_MinimumMode.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
24 changes: 24 additions & 0 deletions core/src/Spirit/Quantities.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <Spirit/Quantities.h>
#include <Spirit/Geometry.h>
#include <data/State.hpp>
#include <engine/HTST.hpp>
#include <engine/Vectormath.hpp>
#include <engine/Manifoldmath.hpp>
#include <engine/Eigenmodes.hpp>
@@ -69,6 +70,29 @@ float Quantity_Get_Topological_Charge(State * state, int idx_image, int idx_chai
}


float Quantity_Get_HTST_Prefactor(State * state, int idx_image_minimum, int idx_image_sp, int idx_chain)
try
{
std::shared_ptr<Data::Spin_System> image_minimum, image_sp;
std::shared_ptr<Data::Spin_System_Chain> chain;
from_indices(state, idx_image_minimum, idx_chain, image_minimum, chain);
from_indices(state, idx_image_sp, idx_chain, image_sp, chain);

auto& info = chain->htst_info;
info.minimum = image_minimum;
info.saddle_point = image_sp;

Engine::HTST::Calculate_Prefactor(chain->htst_info);

return (float)info.prefactor;
}
catch( ... )
{
spirit_handle_exception_api(-1, idx_chain);
return 0;
}


void check_modes(const vectorfield & image, const vectorfield & grad, const MatrixX & tangent_basis, const VectorX & eigenvalues, const MatrixX & eigenvectors_2N, const vectorfield & minimum_mode)
{
using namespace Engine;
1 change: 1 addition & 0 deletions core/src/engine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ set(SOURCE_SPIRIT_ENGINE
${CMAKE_CURRENT_SOURCE_DIR}/Hamiltonian_Heisenberg.cu
${CMAKE_CURRENT_SOURCE_DIR}/Hamiltonian_Gaussian.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Eigenmodes.cpp
${CMAKE_CURRENT_SOURCE_DIR}/HTST.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Method.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Method_LLG.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Method_GNEB.cpp
Loading