Skip to content

Commit

Permalink
GNEB: API getter for equilibrium_delta_Rx
Browse files Browse the repository at this point in the history
  • Loading branch information
M. Sallermann authored and M. Sallermann committed Mar 17, 2022
1 parent 6b0c612 commit cfe8fd8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/include/Spirit/Parameters_GNEB.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ PREFIX bool Parameters_GNEB_Get_Moving_Endpoints( State * state, int idx_chain =
// Set if translating endpoints are used
PREFIX bool Parameters_GNEB_Get_Translating_Endpoints( State * state, int idx_chain = -1 ) SUFFIX;

// Get the equilibrium Rx, used for the moving endpoints method
PREFIX void Parameters_GNEB_Get_Equilibrium_Delta_Rx( State * state, float * delta_Rx_left, float * delta_Rx_right, int idx_chain = -1 ) SUFFIX;

/*
Returns the integer of whether an image is regular, climbing, falling, or stationary.
Expand Down
12 changes: 12 additions & 0 deletions core/python/spirit/parameters/gneb.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,18 @@ def get_translating_endpoints(p_state, idx_chain=-1):
return bool( _GNEB_Get_Translating_Endpoints(ctypes.c_void_p(p_state),
ctypes.c_int(idx_chain)) )

_GNEB_Get_Equilibrium_Delta_Rx = _spirit.Parameters_GNEB_Get_Equilibrium_Delta_Rx
_GNEB_Get_Equilibrium_Delta_Rx.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float), ctypes.c_int]
_GNEB_Get_Equilibrium_Delta_Rx.restype = None
def get_equilibrium_delta_Rx(p_state, idx_chain=-1):
"""Return the equilibrium delta_Rx for the moving endpoints."""
delta_Rx_left = ctypes.c_float()
delta_Rx_right = ctypes.c_float()

_GNEB_Get_Equilibrium_Delta_Rx(ctypes.c_void_p(p_state), ctypes.byref(delta_Rx_left), ctypes.byref(delta_Rx_right), ctypes.c_int(idx_chain))

return [float(delta_Rx_left.value), float(delta_Rx_right.value)]

_GNEB_Get_Climbing_Falling = _spirit.Parameters_GNEB_Get_Climbing_Falling
_GNEB_Get_Climbing_Falling.argtypes = [ctypes.c_void_p, ctypes.c_int, ctypes.c_int]
_GNEB_Get_Climbing_Falling.restype = ctypes.c_int
Expand Down
19 changes: 19 additions & 0 deletions core/src/Spirit/Parameters_GNEB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,25 @@ catch( ... )
return 0;
}

void Parameters_GNEB_Get_Equilibrium_Delta_Rx( State * state, float * delta_Rx_left, float * delta_Rx_right, int idx_chain) noexcept
try
{
int idx_image = -1;
std::shared_ptr<Data::Spin_System> image;
std::shared_ptr<Data::Spin_System_Chain> chain;

// Fetch correct indices and pointers
from_indices( state, idx_image, idx_chain, image, chain );

auto p = chain->gneb_parameters;
*delta_Rx_left = float(p->equilibrium_delta_Rx_left);
*delta_Rx_right = float(p->equilibrium_delta_Rx_right);
}
catch( ... )
{
spirit_handle_exception_api( -1, idx_chain );
}

int Parameters_GNEB_Get_Climbing_Falling( State * state, int idx_image, int idx_chain ) noexcept
try
{
Expand Down

0 comments on commit cfe8fd8

Please sign in to comment.