Skip to content

Commit

Permalink
Ui-QT: Re-enabled Hopfion configuration and added new normal option.
Browse files Browse the repository at this point in the history
  • Loading branch information
Moritz Sallermann committed Dec 8, 2021
1 parent facb560 commit fc7735f
Show file tree
Hide file tree
Showing 5 changed files with 410 additions and 349 deletions.
1 change: 1 addition & 0 deletions core/include/Spirit/Simulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Note that the VP and LBFGS Solvers are only meant for direct minimization and no
// `Solver_VP_OSO`: Verlet-like velocity projection, exponential transform
#define Solver_VP_OSO 7

// A struct that can be passed as an additional argument to the `Simulation_XXX_Start` methods to gather some basic information about the simulation run
struct Simulation_Run_Info
{
int total_iterations = 0;
Expand Down
3 changes: 3 additions & 0 deletions core/python/spirit/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"""

class simulation_run_info(ctypes.Structure):
"""Contains basic information about a simulation run."""
_fields_ = [
("total_iterations", ctypes.c_int),
("total_walltime", ctypes.c_int),
Expand Down Expand Up @@ -132,6 +133,8 @@ def start(p_state, method_type, solver_type=None, n_iterations=-1, n_iterations_
- `n_iterations_log`: the number of iterations after which to log the status and write output (default: take from parameters)
- `single_shot`: if set to `True`, iterations have to be triggered individually
- `idx_image`: the image on which to run the calculation (default: active image). Not used for GNEB
returns a `simulation_run_info` object.
"""

info = simulation_run_info()
Expand Down
107 changes: 49 additions & 58 deletions core/test/test_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,64 +68,55 @@ TEST_CASE( "State", "[state]" )

TEST_CASE( "Configurations", "[configurations]" )
{
auto state = std::shared_ptr<State>( State_Setup( inputfile ), State_Delete );

// filters
float position[3]{ 0, 0, 0 };
float r_cut_rectangular[3]{ -1, -1, -1 };
float r_cut_cylindrical = -1;
float r_cut_spherical = -1;
bool inverted = false;

SECTION( "Domain" )
{
float dir[3] = { 0, 0, 1 };
Configuration_PlusZ( state.get(), position, r_cut_rectangular, r_cut_cylindrical, r_cut_spherical, inverted );
Configuration_MinusZ( state.get(), position, r_cut_rectangular, r_cut_cylindrical, r_cut_spherical, inverted );
Configuration_Domain(
state.get(), dir, position, r_cut_rectangular, r_cut_cylindrical, r_cut_spherical, inverted );
}
SECTION( "Random" )
{
float temperature = 5;
Configuration_Add_Noise_Temperature(
state.get(), temperature, position, r_cut_rectangular, r_cut_cylindrical, r_cut_spherical, inverted );
Configuration_Random( state.get(), position, r_cut_rectangular, r_cut_cylindrical, r_cut_spherical, inverted );
}
SECTION( "Skyrmion" )
{
float r = 5;
int order = 1;
float phase = 0;
bool updown = false, achiral = false, rl = false;
Configuration_Skyrmion(
state.get(), r, order, phase, updown, achiral, rl, position, r_cut_rectangular, r_cut_cylindrical,
r_cut_spherical, inverted );

r = 7;
order = 1;
phase = -90, updown = false;
achiral = true;
rl = false;
Configuration_Skyrmion(
state.get(), r, order, phase, updown, achiral, rl, position, r_cut_rectangular, r_cut_cylindrical,
r_cut_spherical, inverted );
}
SECTION( "Hopfion" )
{
float r = 5;
int order = 1;
Configuration_Hopfion(
state.get(), r, order, position, r_cut_rectangular, r_cut_cylindrical, r_cut_spherical, inverted );
}
SECTION( "Spin Spiral" )
{
auto dir_type = "real lattice";
float q[3]{ 0, 0, 0.1 }, axis[3]{ 0, 0, 1 }, theta{ 30 };
CHECK_NOTHROW( Configuration_SpinSpiral(
state.get(), dir_type, q, axis, theta, position, r_cut_rectangular, r_cut_cylindrical,
r_cut_spherical, inverted ); );
}
auto state = std::shared_ptr<State>(State_Setup(inputfile), State_Delete);

// filters
float position[3]{0,0,0};
float r_cut_rectangular[3]{-1,-1,-1};
float r_cut_cylindrical = -1;
float r_cut_spherical = -1;
bool inverted = false;

SECTION("Domain")
{
float dir[3] = { 0,0,1 };
Configuration_PlusZ(state.get(), position, r_cut_rectangular, r_cut_cylindrical, r_cut_spherical, inverted);
Configuration_MinusZ(state.get(), position, r_cut_rectangular, r_cut_cylindrical, r_cut_spherical, inverted);
Configuration_Domain(state.get(), dir, position, r_cut_rectangular, r_cut_cylindrical, r_cut_spherical, inverted);
}
SECTION("Random")
{
float temperature = 5;
Configuration_Add_Noise_Temperature(state.get(), temperature, position, r_cut_rectangular, r_cut_cylindrical, r_cut_spherical, inverted);
Configuration_Random(state.get(), position, r_cut_rectangular, r_cut_cylindrical, r_cut_spherical, inverted);
}
SECTION("Skyrmion")
{
float r=5;
int order=1;
float phase=0;
bool updown=false, achiral=false, rl=false;
Configuration_Skyrmion(state.get(), r, order, phase, updown, achiral, rl, position, r_cut_rectangular, r_cut_cylindrical, r_cut_spherical, inverted);

r=7;
order=1;
phase=-90,
updown=false; achiral=true; rl=false;
Configuration_Skyrmion(state.get(), r, order, phase, updown, achiral, rl, position, r_cut_rectangular, r_cut_cylindrical, r_cut_spherical, inverted);
}
SECTION("Hopfion")
{
float r=5;
int order=1;
float normal[3] = {0,0,1};
Configuration_Hopfion(state.get(), r, order, position, r_cut_rectangular, r_cut_cylindrical, r_cut_spherical, inverted, normal);
}
SECTION("Spin Spiral")
{
auto dir_type = "real lattice";
float q[3]{0,0,0.1}, axis[3]{0,0,1}, theta{30};
CHECK_NOTHROW( Configuration_SpinSpiral(state.get(), dir_type, q, axis, theta, position, r_cut_rectangular, r_cut_cylindrical, r_cut_spherical, inverted); );
}
}

TEST_CASE( "Quantities", "[quantities]" )
Expand Down
10 changes: 8 additions & 2 deletions ui-cpp/ui-qt/src/ConfigurationsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ConfigurationsWidget::ConfigurationsWidget( std::shared_ptr<State> state, SpinWi
// Setup User Interface
this->setupUi( this );
this->groupBox_globule->setVisible( false );
this->groupBox_hopfion->setVisible( false );
this->groupBox_hopfion->setVisible( true );

// We use a regular expression (regex) to filter the input into the lineEdits
QRegularExpression re( "[+|-]?[\\d]*[\\.]?[\\d]*" );
Expand Down Expand Up @@ -172,8 +172,14 @@ void ConfigurationsWidget::create_Hopfion()
// Create configuration
float r = lineEdit_hopfion_radius->text().toFloat();
int order = lineEdit_hopfion_order->text().toInt();

float normal[3];
normal[0] = lineEdit_hopfion_normal_x->text().toFloat();
normal[1] = lineEdit_hopfion_normal_y->text().toFloat();
normal[2] = lineEdit_hopfion_normal_z->text().toFloat();

Configuration_Hopfion(
this->state.get(), r, order, pos.data(), border_rect.data(), border_cyl, border_sph, inverted );
this->state.get(), r, order, pos.data(), border_rect.data(), border_cyl, border_sph, inverted, normal );

// Optionally add noise
this->configurationAddNoise();
Expand Down
Loading

0 comments on commit fc7735f

Please sign in to comment.