Git Product home page Git Product logo

spinwcore's Introduction

SpinW_Core

This is the core functionality of SpinW written in C++ with a C interface for MATLAB and Python. At the moment it is in development as a proof of concept and DOES NOT WORK!

Requirements

In order to build SpinW_core the following is required:

And OpenMP development libraries if parallelization is required (recomended).

Testing - MATLAB

The library can be used in MATLAB by calling the library through it's C interface:

[notfound, warnings] = loadlibrary(fullfile(pwd,'libSpinW.so'), 'Hspinw.h');

Then transferring the SpinW object (s):

latt  = libstruct('lattice',setfield(s.lattice,'nSymOp',size(s.lattice.sym,3)));
unit_cell = libstruct('unit_cell',setfield(s.unitcell,'nAtom',size(s.unit_cell.r,2)));
twin = libstruct('twin',setfield(s.twin,'nTwin',size(s.twin,2)));
unit = libstruct('unit',s.unit);
mag_str = s.mag_str;
mag_str.F_real = real(mag_str.F);
mag_str.F_imag = imag(mag_str.F);
mag_str.nMagExt = size(mag_str.F,2);

mag_str.nK = size(mag_str.F,3);
mag_str = rmfield(mag_str,'F');
mag_str = libstruct('mag_str',mag_str);

c_sw = calllib('libSpinW','create_sw',latt, unit_cell, twin, mag_str, unit);

Options for the spinwave generation have to be given in a slightly different syntax:

opt = libstruct('spinwave_opt');
opt.notwin = false;
opt.sortMode = true;
opt.optmem = 0;
opt.toll = 1e-4;
opt.hermit = true;
opt.omega_toll = 1e-5;
opt.formfact = false;
opt.gtensor = false;
opt.cmplxBase = false;
opt.tid = -1;
opt.fid = -1;

The HKL range is given by creating a C-pointer where the first 2 elements are the number of HKL end points and number of elements in HKL. i.e from [0 0 0] to [0 0 1] is 2 and the number of elements in [0 0 1] is 3.

hkl = libpointer('doublePtr',[2, 3, 0 0 0, 0 0 1, 10])

The spectrum can be calculated by calling sw_spinwave and a double C-Pointer to the memory address is returned.

sw_spec = calllib('libSpinW','sw_spinwave',c_sw,hkl,opt)

Testing - Python

A C interface for the spinwave function is available but more development is needed.

spinwcore's People

Contributors

wardsimon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.