Skip to content

Commit

Permalink
Added initial implementation of localized temperature pulse
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-evans committed Aug 11, 2014
1 parent 3a64529 commit 35cc3a4
Show file tree
Hide file tree
Showing 18 changed files with 1,156 additions and 2 deletions.
105 changes: 105 additions & 0 deletions hdr/ltmp.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
//-----------------------------------------------------------------------------
//
// This header file is part of the VAMPIRE open source package under the
// GNU GPL (version 2) licence (see licence file for details).
//
// (c) R F L Evans 2014. All rights reserved.
//
//-----------------------------------------------------------------------------
//
// Functions to calculate dynamic lateral and vertical temperature
// profiles with the two temperature model. Laser has gaussian absorption
// profile in x,y and an exponential decrease in absorption with increasing
// depth (z).
//
// |
// |
// |
// |
// |
// _-_
// / \
// __-- --__
// ----------------------
// | | | | | | | |
// ----------------------
// | | | | | | | |
// ----------------------
//
// The deposited laser energy is modified laterally by a gaussian heat profile
// given by
//
// P(r) = exp (-4 ln(2.0) (r**2) / (fwhm**2) )
//
// and/or vertically considering an exponential depth dependence of the laser
// energy given by
//
// P(z) = exp(-z/penetration-depth)
//
// Both of these can be combined to give a full 3D solution of the two
// temperature model, including dynamic heat distribution within the sample.

// System headers
#include <string>
#include <vector>

// Program headers

#ifndef LOCALTEMPERATURE_H_
#define LOCALTEMPERATURE_H_

//--------------------------------------------------------------------------------
// Namespace for variables and functions to calculate localised temperature pulse
//--------------------------------------------------------------------------------
namespace ltmp{

//-----------------------------------------------------------------------------
// Variables used for the localised temperature pulse calculation
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// Function to check local temperature pulse is enabled
//-----------------------------------------------------------------------------
bool is_enabled();

//-----------------------------------------------------------------------------
// Function to initialise localised temperature pulse calculation
//-----------------------------------------------------------------------------
void initialise(const double system_dimensions_x,
const double system_dimensions_y,
const double system_dimensions_z,
const std::vector<double>& atom_coords_x,
const std::vector<double>& atom_coords_y,
const std::vector<double>& atom_coords_z,
const std::vector<int>& atom_type_array,
const int num_local_atoms,
const double starting_temperature,
const double pump_power,
const double pump_time,
const double TTG,
const double TTCe,
const double TTCl,
const double dt);

//-----------------------------------------------------------------------------
// Function to copy localised thermal fields to external field array
//-----------------------------------------------------------------------------
void get_localised_thermal_fields(std::vector<double>& x_total_external_field_array,
std::vector<double>& y_total_external_field_array,
std::vector<double>& z_total_external_field_array,
const int start_index,
const int end_index);

//-----------------------------------------------------------------------------
// Function for updating localised temperature
//-----------------------------------------------------------------------------
void update_localised_temperature(const double start_from_start);

//-----------------------------------------------------------------------------
// Function to process input file parameters for ltmp settings
//-----------------------------------------------------------------------------
bool match_input_parameter(std::string const key, std::string const word, std::string const value, std::string const unit, int const line);

} // end of ltmp namespace

#endif // LOCALTEMPERATURE_H_
1 change: 1 addition & 0 deletions hdr/program.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ namespace program
extern void hybrid_cmc();
extern void reverse_hybrid_cmc();
extern void lagrange_multiplier();
extern void localised_temperature_pulse();

// Sundry programs and diagnostics not under general release
extern int LLB_Boltzmann();
Expand Down
18 changes: 17 additions & 1 deletion hdr/vio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,23 @@ void terminaltextcolor(enum textcolor );
extern std::string zTs();

namespace vin{
extern int read(std::string const);
extern int read(std::string const);

extern void check_for_valid_value(double& value, std::string word, int line, std::string prefix, std::string unit, std::string unit_type,
double range_min, double range_max, std::string input_file_type, std::string range_text);

extern void check_for_valid_int(int& value, std::string word, int line, std::string prefix, int range_min, int range_max,
std::string input_file_type, std::string range_text);

extern void check_for_valid_int( unsigned int& value, std::string word, int line, std::string prefix, unsigned int range_min,
unsigned int range_max, std::string input_file_type, std::string range_text);

extern bool check_for_valid_bool( std::string value, std::string word, int line, std::string prefix, std::string input_file_type);

extern void check_for_valid_unit_vector(std::vector<double>& u, std::string word, int line, std::string prefix, std::string input_file_type);

extern void check_for_valid_vector(std::vector<double>& u, std::string word, int line, std::string prefix, std::string input_file_type);

}

namespace vout{
Expand Down
8 changes: 8 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ obj/data/category.o \
obj/data/cells.o \
obj/data/grains.o \
obj/data/lattice_anisotropy.o \
obj/ltmp/data.o \
obj/ltmp/field.o \
obj/ltmp/initialise.o \
obj/ltmp/interface.o \
obj/ltmp/is_enabled.o \
obj/ltmp/local_temperature.o \
obj/ltmp/output.o \
obj/main/initialise_variables.o \
obj/main/main.o \
obj/main/material.o \
Expand All @@ -92,6 +99,7 @@ obj/program/partial_hysteresis.o \
obj/program/static_hysteresis.o \
obj/program/time_series.o \
obj/program/temperature_pulse.o \
obj/program/localised_temperature_pulse.o \
obj/random/mtrand.o \
obj/random/random.o \
obj/simulate/energy.o \
Expand Down
Empty file added obj/ltmp/.gitignore
Empty file.
26 changes: 26 additions & 0 deletions src/create/create_system2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include "cells.hpp"
#include "demag.hpp"
#include "grains.hpp"
#include "ltmp.hpp"
#include "material.hpp"
#include "sim.hpp"
#include "vio.hpp"
Expand Down Expand Up @@ -284,6 +285,31 @@ int create(){
cells::initialise();
if(sim::hamiltonian_simulation_flags[4]==1) demag::init();

// Determine number of local atoms
#ifdef MPICF
int num_local_atoms = vmpi::num_core_atoms+vmpi::num_bdry_atoms;
#else
int num_local_atoms = atoms::num_atoms;
#endif
//----------------------------------------
// Initialise local temperature data
//----------------------------------------
ltmp::initialise(cs::system_dimensions[0],
cs::system_dimensions[1],
cs::system_dimensions[2],
atoms::x_coord_array,
atoms::y_coord_array,
atoms::z_coord_array,
atoms::type_array,
num_local_atoms,
sim::Teq,
sim::pump_power,
sim::pump_time,
sim::TTG,
sim::TTCe,
sim::TTCl,
mp::dt_SI);

//std::cout << num_atoms << std::endl;
#ifdef MPICF
//std::cout << "Outputting coordinate data" << std::endl;
Expand Down
66 changes: 66 additions & 0 deletions src/ltmp/data.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//-----------------------------------------------------------------------------
//
// This source file is part of the VAMPIRE open source package under the
// GNU GPL (version 2) licence (see licence file for details).
//
// (c) R F L Evans 2014. All rights reserved.
//
//-----------------------------------------------------------------------------

// C++ standard library headers

// Vampire headers
#include "ltmp.hpp"

// Local temperature pulse headers
#include "internal.hpp"

namespace ltmp{
namespace internal{
//-----------------------------------------------------------------------------
// Shared variables used for the local temperature pulse calculation
//-----------------------------------------------------------------------------
bool enabled=true; //false; /// enable localised local temperature pulse
bool initialised=false; /// flag set if initialised
bool lateral_discretisation=false; /// enable lateral temperature profile
bool vertical_discretisation=true; /// enable vertical temperature profile
bool output_microcell_data=false; /// enable verbose output data for temperature cells

double micro_cell_size = 10.0; /// lateral size of local temperature microcells (A)
double laser_spot_size = 350.0; /// laser spot size for lateral profile (A)
double penetration_depth = 200.0; /// vertical laser penetration depth
double thermal_conductivity = 11.0; //J/s/m/K

double pump_power; // laser pump power
double pump_time; // laser pump time (s)
double TTG; // electron-lattice coupling constant
double TTCe; // electron heat capacity (T=0)
double TTCl; // lattice heat capcity
double dt; // time step

int num_local_atoms; /// number of local atoms (ignores halo atoms in parallel simulation)
int num_cells; /// number of temperature cells
int my_first_cell; /// first cell on my CPU
int my_last_cell; /// last cell on my CPU

std::vector<int> atom_temperature_index; /// defines which temperature cell applies to atom (including Te or Tp)
std::vector<double> atom_sigma; /// unrolled list of thermal prefactor sqrt(2kBalpha/gamma*mu_s*dt)

std::vector<int> cell_neighbour_list; // list of cell interactions for heat transfer
std::vector<int> cell_neighbour_start_index; // start index of interactions for cell
std::vector<int> cell_neighbour_end_index; // end index of interactions for cell

std::vector<double> x_field_array; /// arrays to store atomic temperature field
std::vector<double> y_field_array;
std::vector<double> z_field_array;

std::vector<double> root_temperature_array; /// stored as pairs sqrt(Te), sqrt(Tp) (2 x number of cells) MIRRORED on all CPUs
std::vector<double> cell_position_array; /// position of cells in x,y,z (3*n) MIRRORED on all CPUs // dont need this
std::vector<double> delta_temperature_array; /// stored as pairs dTe, dTp LOCAL CPU only
std::vector<double> attenuation_array; /// factor reducng incident laser fluence for each cell LOCAL CPU only

//std::vector<double> material_kerr_sensitivity_depth; // unrolled list of kerr sensitivity depths for each material

} // end of internal namespace
} // end of ltmp namespace

68 changes: 68 additions & 0 deletions src/ltmp/field.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//-----------------------------------------------------------------------------
//
// This source file is part of the VAMPIRE open source package under the
// GNU GPL (version 2) licence (see licence file for details).
//
// (c) R F L Evans 2014. All rights reserved.
//
//-----------------------------------------------------------------------------

// C++ standard library headers

// Vampire headers
#include "ltmp.hpp"
#include "random.hpp"

// Local temperature pulse headers
#include "internal.hpp"

namespace ltmp{

//-----------------------------------------------------------------------------
// Function for updating local temperature fields
//-----------------------------------------------------------------------------
void update_localised_temperature(const double time_from_start){

// calculate local temperature
ltmp::internal::calculate_local_temperature(time_from_start);

// store number of local atoms as local constant for compiler
const int num_local_atoms = ltmp::internal::num_local_atoms;

// Initialise thermal field random numbers
generate (ltmp::internal::x_field_array.begin(),ltmp::internal::x_field_array.begin()+num_local_atoms, mtrandom::gaussian);
generate (ltmp::internal::y_field_array.begin(),ltmp::internal::y_field_array.begin()+num_local_atoms, mtrandom::gaussian);
generate (ltmp::internal::z_field_array.begin(),ltmp::internal::z_field_array.begin()+num_local_atoms, mtrandom::gaussian);

// calculate local thermal field for all atoms
for(int atom=0; atom<ltmp::internal::num_local_atoms; ++atom) {
const int cell = ltmp::internal::atom_temperature_index[atom]; /// get cell index for atom temperature (Te or Tp)
const double rootT = ltmp::internal::root_temperature_array[cell]; /// get sqrt(T) for atom
const double sigma = ltmp::internal::atom_sigma[atom]; /// unrolled list of thermal prefactor

ltmp::internal::x_field_array[atom]*= sigma*rootT;
ltmp::internal::y_field_array[atom]*= sigma*rootT;
ltmp::internal::z_field_array[atom]*= sigma*rootT;
}

return;
}

//-----------------------------------------------------------------------------
// Function for adding local thermal fields to external field array
//-----------------------------------------------------------------------------
void get_localised_thermal_fields(std::vector<double>& x_total_external_field_array,
std::vector<double>& y_total_external_field_array,
std::vector<double>& z_total_external_field_array,
const int start_index,
const int end_index){

// Add spin torque fields
for(int i=start_index; i<end_index; ++i) x_total_external_field_array[i] += ltmp::internal::x_field_array[i];
for(int i=start_index; i<end_index; ++i) y_total_external_field_array[i] += ltmp::internal::y_field_array[i];
for(int i=start_index; i<end_index; ++i) z_total_external_field_array[i] += ltmp::internal::z_field_array[i];

return;
}

} // end of ltmp namespace
Loading

0 comments on commit 35cc3a4

Please sign in to comment.