From 9d00f130e6fe43a67b4bbcb5a8ecdf5e6e2915fd Mon Sep 17 00:00:00 2001 From: Florian Rhiem Date: Tue, 23 Apr 2019 13:05:11 +0200 Subject: [PATCH 01/16] Updated default emscripten root --- CMake/ChooseCompiler.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMake/ChooseCompiler.cmake b/CMake/ChooseCompiler.cmake index 4fcad3369..0e3e18a2c 100644 --- a/CMake/ChooseCompiler.cmake +++ b/CMake/ChooseCompiler.cmake @@ -5,7 +5,7 @@ if (SPIRIT_BUILD_FOR_JS) ### MESSAGE( STATUS ">> Choosing compiler: emcc" ) ### Set the path to emscripten - SET(EMSCRIPTEN_ROOT_PATH "/usr/local/emsdk_portable/emscripten/1.35.0/") + SET(EMSCRIPTEN_ROOT_PATH "/usr/local/emsdk/emscripten/1.38.29/") ### Use the Emscripten toolchain file SET(CMAKE_TOOLCHAIN_FILE Emscripten) ###################################################################### From 226bbfa552ae088c735c0bbe6448847663bffca8 Mon Sep 17 00:00:00 2001 From: Florian Rhiem Date: Tue, 23 Apr 2019 13:05:45 +0200 Subject: [PATCH 02/16] Fixed list of exported symbols --- ui-web/CMakeLists.txt | 305 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 268 insertions(+), 37 deletions(-) diff --git a/ui-web/CMakeLists.txt b/ui-web/CMakeLists.txt index 7df8ad5a5..b93f3bb31 100644 --- a/ui-web/CMakeLists.txt +++ b/ui-web/CMakeLists.txt @@ -43,48 +43,279 @@ set(SOURCE_UI_WEB_ROOT) ######## Set export functions for Web UI ############################# ### Place all functions which should be exported by emcc into this list set( INTERFACE_EXPORT_FUNCTIONS - '_Spirit_Version' '_Spirit_Version_Revision' '_Spirit_Version_Full' - # State - '_State_Setup' - # System - '_System_Get_Index' '_System_Get_NOS' '_System_Get_Spin_Directions' # Chain - '_Chain_Get_Index' '_Chain_Get_NOI' - '_Chain_next_Image' '_Chain_prev_Image' - '_Chain_Image_to_Clipboard' '_Chain_Insert_Image_Before' '_Chain_Insert_Image_After' '_Chain_Replace_Image' '_Chain_Delete_Image' - '_Chain_Update_Data' '_Chain_Setup_Data' - # Collection - '_Collection_Get_NOC' - '_Collection_next_Chain' '_Collection_prev_Chain' + '_Chain_Get_NOI' + '_Chain_next_Image' + '_Chain_prev_Image' + '_Chain_Jump_To_Image' + '_Chain_Set_Length' + '_Chain_Image_to_Clipboard' + '_Chain_Replace_Image' + '_Chain_Insert_Image_Before' + '_Chain_Insert_Image_After' + '_Chain_Push_Back' + '_Chain_Delete_Image' + '_Chain_Pop_Back' + '_Chain_Get_Rx' + '_Chain_Get_Rx_Interpolated' + '_Chain_Get_Energy' + '_Chain_Get_Energy_Interpolated' + '_Chain_Get_HTST_Info' + '_Chain_Update_Data' + '_Chain_Setup_Data' + # Configuration + '_Configuration_To_Clipboard' + '_Configuration_From_Clipboard' + '_Configuration_From_Clipboard_Shift' + '_Configuration_Domain' + '_Configuration_PlusZ' + '_Configuration_MinusZ' + '_Configuration_Random' + '_Configuration_SpinSpiral' + '_Configuration_SpinSpiral_2q' + '_Configuration_Add_Noise_Temperature' + '_Configuration_Displace_Eigenmode' + '_Configuration_Skyrmion' + '_Configuration_Hopfion' + '_Configuration_Set_Pinned' + '_Configuration_Set_Atom_Type' + # Constants + '_Constants_mu_B' + '_Constants_mu_0' + '_Constants_k_B' + '_Constants_hbar' + '_Constants_mRy' + '_Constants_gamma' + '_Constants_g_e' + '_Constants_Pi' # Geometry + '_Geometry_Set_Bravais_Lattice_Type' + '_Geometry_Set_N_Cells' + '_Geometry_Set_Cell_Atoms' + '_Geometry_Set_mu_s' + '_Geometry_Set_Cell_Atom_Types' + '_Geometry_Set_Bravais_Vectors' + '_Geometry_Set_Lattice_Constant' + '_Geometry_Get_NOS' '_Geometry_Get_Positions' - '_Geometry_Set_mu_s' '_Geometry_Get_mu_s' - '_Geometry_Get_Bounds' '_Geometry_Get_Center' - '_Geometry_Get_Basis_Vectors' '_Geometry_Get_N_Cells' '_Geometry_Get_Translation_Vectors' '_Geometry_Get_Dimensionality' + '_Geometry_Get_Atom_Types' + '_Geometry_Get_Bounds' + '_Geometry_Get_Center' + '_Geometry_Get_Bravais_Lattice_Type' + '_Geometry_Get_Bravais_Vectors' + '_Geometry_Get_Dimensionality' + '_Geometry_Get_mu_s' + '_Geometry_Get_N_Cells' + '_Geometry_Get_Cell_Bounds' + '_Geometry_Get_N_Cell_Atoms' + '_Geometry_Get_Cell_Atoms' + '_Geometry_Get_Triangulation' + '_Geometry_Get_Tetrahedra' # Hamiltonian - '_Hamiltonian_Set_Boundary_Conditions' '_Hamiltonian_Set_Field' '_Hamiltonian_Set_Exchange' '_Hamiltonian_Set_DMI' '_Hamiltonian_Set_Anisotropy' '_Hamiltonian_Set_DDI' - '_Hamiltonian_Get_Boundary_Conditions' '_Hamiltonian_Get_Field' '_Hamiltonian_Get_Exchange' '_Hamiltonian_Get_DMI' '_Hamiltonian_Get_Anisotropy' - # Parameters LLG - '_Parameters_LLG_Set_Time_Step' '_Parameters_LLG_Set_Damping' - '_Parameters_LLG_Set_STT' '_Parameters_LLG_Set_Temperature' + '_Hamiltonian_Set_Boundary_Conditions' + '_Hamiltonian_Set_Field' + '_Hamiltonian_Set_Anisotropy' + '_Hamiltonian_Set_Exchange' + '_Hamiltonian_Set_DMI' + '_Hamiltonian_Set_DDI' + '_Hamiltonian_Get_Name' + '_Hamiltonian_Get_Boundary_Conditions' + '_Hamiltonian_Get_Field' + '_Hamiltonian_Get_Anisotropy' + '_Hamiltonian_Get_Exchange_Shells' + '_Hamiltonian_Get_Exchange_N_Pairs' + '_Hamiltonian_Get_Exchange_Pairs' + '_Hamiltonian_Get_DMI_Shells' + '_Hamiltonian_Get_DMI_N_Pairs' + '_Hamiltonian_Get_DDI' + # IO + '_IO_System_From_Config' + '_IO_Positions_Write' + '_IO_N_Images_In_File' + '_IO_Image_Read' + '_IO_Image_Write' + '_IO_Image_Append' + '_IO_Chain_Read' + '_IO_Chain_Write' + '_IO_Chain_Append' + '_IO_Image_Write_Neighbours_Exchange' + '_IO_Image_Write_Neighbours_DMI' + '_IO_Image_Write_Energy_per_Spin' + '_IO_Image_Write_Energy' + '_IO_Chain_Write_Energies' + '_IO_Chain_Write_Energies_Interpolated' + '_IO_Eigenmodes_Read' + '_IO_Eigenmodes_Write' + # Log + '_Log_Send' + '_Log_Append' + '_Log_Dump' + '_Log_Get_N_Entries' + '_Log_Get_N_Errors' + '_Log_Get_N_Warnings' + '_Log_Set_Output_File_Tag' + '_Log_Set_Output_Folder' + '_Log_Set_Output_To_Console' + '_Log_Set_Output_To_File' + '_Log_Get_Output_File_Tag' + '_Log_Get_Output_Folder' + '_Log_Get_Output_To_Console' + '_Log_Get_Output_Console_Level' + '_Log_Get_Output_To_File' + '_Log_Get_Output_File_Level' + # Parameters (EMA) + '_Parameters_EMA_Set_N_Modes' + '_Parameters_EMA_Set_N_Mode_Follow' + '_Parameters_EMA_Set_Frequency' + '_Parameters_EMA_Set_Amplitude' + '_Parameters_EMA_Set_Snapshot' + '_Parameters_EMA_Get_N_Modes' + '_Parameters_EMA_Get_N_Mode_Follow' + '_Parameters_EMA_Get_Frequency' + '_Parameters_EMA_Get_Amplitude' + '_Parameters_EMA_Get_Snapshot' + '_Parameters_GNEB_Set_Output_Tag' + '_Parameters_GNEB_Set_Output_Folder' + '_Parameters_GNEB_Set_Output_General' + '_Parameters_GNEB_Set_Output_Energies' + '_Parameters_GNEB_Set_Output_Chain' + '_Parameters_GNEB_Set_N_Iterations' + '_Parameters_GNEB_Set_Convergence' + '_Parameters_GNEB_Set_Spring_Constant' + '_Parameters_GNEB_Set_Spring_Force_Ratio' + '_Parameters_GNEB_Set_Path_Shortening_Constant' + '_Parameters_GNEB_Set_Climbing_Falling' + '_Parameters_GNEB_Set_Image_Type_Automatically' + '_Parameters_GNEB_Set_N_Energy_Interpolations' + '_Parameters_GNEB_Get_Output_Tag' + '_Parameters_GNEB_Get_Output_Folder' + '_Parameters_GNEB_Get_Output_General' + '_Parameters_GNEB_Get_Output_Energies' + '_Parameters_GNEB_Get_Output_Chain' + '_Parameters_GNEB_Get_N_Iterations' + '_Parameters_GNEB_Get_Convergence' + '_Parameters_GNEB_Get_Spring_Constant' + '_Parameters_GNEB_Get_Spring_Force_Ratio' + '_Parameters_GNEB_Get_Path_Shortening_Constant' + '_Parameters_GNEB_Get_Climbing_Falling' + '_Parameters_GNEB_Get_N_Energy_Interpolations' + # Parameters (LLG) + '_Parameters_LLG_Set_Output_Tag' + '_Parameters_LLG_Set_Output_Folder' + '_Parameters_LLG_Set_Output_General' + '_Parameters_LLG_Set_Output_Energy' + '_Parameters_LLG_Set_Output_Configuration' + '_Parameters_LLG_Set_N_Iterations' + '_Parameters_LLG_Set_Direct_Minimization' '_Parameters_LLG_Set_Convergence' - '_Parameters_LLG_Get_Time_Step' '_Parameters_LLG_Get_Damping' - '_Parameters_LLG_Get_STT' '_Parameters_LLG_Get_Temperature' - # Parameters GNEB - '_Parameters_Set_GNEB_Spring_Constant' '_Parameters_Set_GNEB_Climbing_Falling' - '_Parameters_Get_GNEB_Spring_Constant' '_Parameters_Get_GNEB_Climbing_Falling' '_Parameters_Get_GNEB_N_Energy_Interpolations' - # Configurations - '_Configuration_Domain' '_Configuration_PlusZ' '_Configuration_MinusZ' - '_Configuration_Random' '_Configuration_Add_Noise_Temperature' '_Configuration_Skyrmion' '_Configuration_SpinSpiral' - # Transitions - '_Transition_Homogeneous' '_Transition_Add_Noise_Temperature' + '_Parameters_LLG_Set_Time_Step' + '_Parameters_LLG_Set_Damping' + '_Parameters_LLG_Set_STT' + '_Parameters_LLG_Set_Temperature' + '_Parameters_LLG_Set_Temperature_Gradient' + '_Parameters_LLG_Get_Output_Tag' + '_Parameters_LLG_Get_Output_Folder' + '_Parameters_LLG_Get_Output_General' + '_Parameters_LLG_Get_Output_Energy' + '_Parameters_LLG_Get_Output_Configuration' + '_Parameters_LLG_Get_N_Iterations' + '_Parameters_LLG_Get_Direct_Minimization' + '_Parameters_LLG_Get_Convergence' + '_Parameters_LLG_Get_Time_Step' + '_Parameters_LLG_Get_Damping' + '_Parameters_LLG_Get_Temperature' + '_Parameters_LLG_Get_Temperature_Gradient' + '_Parameters_LLG_Get_STT' + # Parameters (MC) + '_Parameters_MC_Set_Output_Tag' + '_Parameters_MC_Set_Output_Folder' + '_Parameters_MC_Set_Output_General' + '_Parameters_MC_Set_Output_Energy' + '_Parameters_MC_Set_Output_Configuration' + '_Parameters_MC_Set_N_Iterations' + '_Parameters_MC_Set_Temperature' + '_Parameters_MC_Set_Metropolis_Cone' + '_Parameters_MC_Set_Random_Sample' + '_Parameters_MC_Get_Output_Tag' + '_Parameters_MC_Get_Output_Folder' + '_Parameters_MC_Get_Output_General' + '_Parameters_MC_Get_Output_Energy' + '_Parameters_MC_Get_Output_Configuration' + '_Parameters_MC_Get_N_Iterations' + '_Parameters_MC_Get_Temperature' + '_Parameters_MC_Get_Metropolis_Cone' + '_Parameters_MC_Get_Random_Sample' + # Parameters (MMF) + '_Parameters_MMF_Set_Output_Tag' + '_Parameters_MMF_Set_Output_Folder' + '_Parameters_MMF_Set_Output_General' + '_Parameters_MMF_Set_Output_Energy' + '_Parameters_MMF_Set_Output_Configuration' + '_Parameters_MMF_Set_N_Iterations' + '_Parameters_MMF_Set_N_Modes' + '_Parameters_MMF_Set_N_Mode_Follow' + '_Parameters_MMF_Get_Output_Tag' + '_Parameters_MMF_Get_Output_Folder' + '_Parameters_MMF_Get_Output_General' + '_Parameters_MMF_Get_Output_Energy' + '_Parameters_MMF_Get_Output_Configuration' + '_Parameters_MMF_Get_N_Iterations' + '_Parameters_MMF_Get_N_Modes' + '_Parameters_MMF_Get_N_Mode_Follow' + # Quantity + '_Quantity_Get_Magnetization' + '_Quantity_Get_Topological_Charge' + '_Quantity_Get_Grad_Force_MinimumMode' + '_Quantity_Get_HTST_Prefactor' # Simulation - '_Simulation_MC_Start' '_Simulation_LLG_Start' '_Simulation_GNEB_Start' - '_Simulation_SingleShot' '_Simulation_Stop' '_Simulation_Stop_All' - '_Simulation_Running_Image' '_Simulation_Running_Chain' '_Simulation_Running_Collection' - '_Simulation_Running_Anywhere_Chain' '_Simulation_Running_Anywhere_Collection' - # Log - '_Log_Send' '_Log_Get_N_Entries' '_Log_Append' '_Log_Dump' + '_Simulation_MC_Start' + '_Simulation_LLG_Start' + '_Simulation_GNEB_Start' + '_Simulation_MMF_Start' + '_Simulation_EMA_Start' + '_Simulation_SingleShot' + '_Simulation_Stop' + '_Simulation_Stop_All' + '_Simulation_Get_MaxTorqueComponent' + '_Simulation_Get_Chain_MaxTorqueComponents' + '_Simulation_Get_IterationsPerSecond' + '_Simulation_Get_Iteration' + '_Simulation_Get_Time' + '_Simulation_Get_Wall_Time' + '_Simulation_Get_Solver_Name' + '_Simulation_Get_Method_Name' + '_Simulation_Running_On_Image' + '_Simulation_Running_On_Chain' + '_Simulation_Running_Anywhere_On_Chain' + # Spirit + '_Spirit_Version_Major' + '_Spirit_Version_Minor' + '_Spirit_Version_Patch' + '_Spirit_Version' + '_Spirit_Version_Revision' + '_Spirit_Version_Full' + # State + '_State_Setup' + '_State_Delete' + '_State_Update' + '_State_To_Config' + '_State_DateTime' + # System + '_System_Get_Index' + '_System_Get_NOS' + '_System_Get_Spin_Directions' + '_System_Get_Effective_Field' + '_System_Get_Eigenmode' + '_System_Get_Rx' + '_System_Get_Energy' + '_System_Get_Energy_Array' + '_System_Get_Eigenvalues' + '_System_Print_Energy_Array' + '_System_Update_Data' + '_System_Update_Eigenmodes' + # Transition + '_Transition_Homogeneous' + '_Transition_Add_Noise_Temperature' ) ### Replace ; in the list with , while transforming into a string string( REPLACE ";" ", " INTERFACE_EXPORT_FUNCTIONS_STRING "${INTERFACE_EXPORT_FUNCTIONS}") @@ -116,4 +347,4 @@ endif( ) MESSAGE( STATUS ">> --------------------- UI - Web done -------------------------------- <<" ) -MESSAGE( STATUS ">> -------------------------------------------------------------------- <<" ) \ No newline at end of file +MESSAGE( STATUS ">> -------------------------------------------------------------------- <<" ) From 456e3ab0091a1cf5be630731ae934012cbfb6bbd Mon Sep 17 00:00:00 2001 From: Florian Rhiem Date: Tue, 23 Apr 2019 13:06:08 +0200 Subject: [PATCH 03/16] Allow resizing grid in web UI --- ui-web/js/simulation.js | 13 +++++++++++++ ui-web/js/ui.js | 10 ++++++++++ ui-web/js/webglspins.js | 10 ++++++++++ ui-web/web.html | 25 +++++++++++++++++++++++++ 4 files changed, 58 insertions(+) diff --git a/ui-web/js/simulation.js b/ui-web/js/simulation.js index 0c9b80ecd..8e5dde321 100644 --- a/ui-web/js/simulation.js +++ b/ui-web/js/simulation.js @@ -333,4 +333,17 @@ Module.ready(function() { Module._free(ncells_ptr); return [NX, NY, NZ]; } + Module.Geometry_Set_N_Cells = Module.cwrap('Geometry_Set_N_Cells', null, ['number', 'number']); + Simulation.prototype.setNCells = function (n_cells) { + var ncells_ptr = Module._malloc(3*Module.HEAP32.BYTES_PER_ELEMENT); + var na_ptr = ncells_ptr+0*Module.HEAP32.BYTES_PER_ELEMENT; + var nb_ptr = ncells_ptr+1*Module.HEAP32.BYTES_PER_ELEMENT; + var nc_ptr = ncells_ptr+2*Module.HEAP32.BYTES_PER_ELEMENT; + Module.HEAP32[na_ptr/Module.HEAP32.BYTES_PER_ELEMENT] = n_cells[0]; + Module.HEAP32[nb_ptr/Module.HEAP32.BYTES_PER_ELEMENT] = n_cells[1]; + Module.HEAP32[nc_ptr/Module.HEAP32.BYTES_PER_ELEMENT] = n_cells[2]; + Module.Geometry_Set_N_Cells(this._state, ncells_ptr); + Module._free(ncells_ptr); + this.update(); + } }); diff --git a/ui-web/js/ui.js b/ui-web/js/ui.js index 6ec601610..00535535d 100644 --- a/ui-web/js/ui.js +++ b/ui-web/js/ui.js @@ -104,6 +104,16 @@ $(document).ready(function() { sim.setAllSpinsRandom(); }); + + $('#button-gridsize-update').on('click', function(e) { + var x = Number($('#input-gridsize-x').val()); + var y = Number($('#input-gridsize-y').val()); + var z = Number($('#input-gridsize-z').val()); + var sim = window.currentSimulation; + sim.setNCells([x, y, z]); + webglspins.updateCenterLocation([(x-1)/2, (y-1)/2, (z-1)/2]); + }); + $('#button-skyrmion-create').on('click', function(e) { var order = Number($('#input-skyrmion-order').val()); var phase = Number($('#input-skyrmion-phase').val()); diff --git a/ui-web/js/webglspins.js b/ui-web/js/webglspins.js index 449250814..7916be6c6 100644 --- a/ui-web/js/webglspins.js +++ b/ui-web/js/webglspins.js @@ -283,6 +283,16 @@ WebGLSpins.prototype.alignCamera = function(forward, up) { this.draw(); }; +WebGLSpins.prototype.updateCenterLocation = function(centerLocation) { + this._options.cameraLocation[0] = this._options.cameraLocation[0] - this._options.centerLocation[0] + centerLocation[0]; + this._options.cameraLocation[1] = this._options.cameraLocation[1] - this._options.centerLocation[1] + centerLocation[1]; + this._options.cameraLocation[2] = this._options.cameraLocation[2] - this._options.centerLocation[2] + centerLocation[2]; + this._options.centerLocation[0] = centerLocation[0]; + this._options.centerLocation[1] = centerLocation[1]; + this._options.centerLocation[2] = centerLocation[2]; + this.draw(); +}; + WebGLSpins.prototype._rotationHelper = function(deltaX, deltaY) { var forwardVector = WebGLSpins._difference(this._options.centerLocation, this._options.cameraLocation); var cameraDistance = WebGLSpins._length(forwardVector); diff --git a/ui-web/web.html b/ui-web/web.html index 75562dc9a..110f91d93 100644 --- a/ui-web/web.html +++ b/ui-web/web.html @@ -25,6 +25,31 @@