Skip to content

A MATLAB interface to the CuH2 potential of the Jonsson group

License

Notifications You must be signed in to change notification settings

TheochemUI/mex_cuh2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

A lot of inherited code unfortunately uses MATLAB. File I/O interfaces are horrible. This has a slightly less horrible implementation. The C-Fortran interface is tested in potlib anyway, so only the bindings need to be checked here.

For a copper slab and hydrogen molecule, the potential is qualitatively correct. It captures the fact that when the slab is fixed, there are effectively only two degrees of freedom, the distance between the hydrogen atoms, and the distance to the slab.

I find it easier to work in C for the interface to MATLAB.

Compilation

tup init
tup # single build
ls src/*.c src/fortran/*.f90 | entr tup # Linux
watchexec --exts c,f90 -- tup # Cross platform

To really get down to it, this works too:

gfortran -shared -fPIC -o libcuH2Fort.so eam_isoc.f90 eamroutines.f90
mex -I$(pwd) -L$(pwd) -lcuH2Fort cuh2_mex.c

Though the tup formulation is preferred. There’s no default clean but if everything is commited, there’s always git clean -dfxn, remove -n if the dry-run looks alright.

Usage

The library needs to be accessible to matlab so the simplest approach is just:

LD_LIBRARY_PATH=$(pwd) matlab -nosplash -nodesktop

Now running things can be as simple as:

R = [0.63940268750835, 0.90484742551374, 6.97516498544584; 3.19652040936288, 0.90417430354811, 6.97547796369474; 8.98363230369760, 9.94703496017833, 7.83556854923689; 7.64080177576300, 9.94703114803832, 7.83556986121272];
atm_nrs = int32([29, 29, 1, 1]);
box = [15.345599999999999, 0, 0; 0, 21.702000000000002, 0; 0, 0, 100.00000000000000];
cuh2_mex(R, atm_nrs, box)

To save some typing, we can also just load the data.

LD_LIBRARY_PATH=$(pwd) matlab -nosplash -nodesktop -r "load('data/test_vals')"
cuh2_mex(R, atm_nrs, box)

Tests, such as they are can be run as:

LD_LIBRARY_PATH=$(pwd) matlab -nosplash -nodesktop -batch "runtests"

License

MIT.

About

A MATLAB interface to the CuH2 potential of the Jonsson group

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published