Skip to content

Commit

Permalink
Merge pull request #32 from rikigigi/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
rikigigi authored Apr 26, 2023
2 parents ce11cc6 + 6177cb5 commit 7b68dad
Show file tree
Hide file tree
Showing 21 changed files with 30,263 additions and 29,149 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest ]
python-version: [ "3.7" ]
python-version: [ "3.7", "3.11" ]
steps:
- uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
strategy:
matrix:
os: [windows-latest ]
python-version: [ "3.7" ]
python-version: [ "3.7", "3.11" ]
steps:
- uses: actions/checkout@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ if(PYTHON_INTERFACE)
if (${PYTHONLIBS_FOUND})
#python interface
set (PYTHON_SUPPORT ${PYTHON_LIBRARIES})
#target_link_libraries(${PROJECT_NAME} PRIVATE pybind11::module)
target_link_libraries(${PROJECT_NAME}_lib PUBLIC pybind11::embed)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS})
include_directories(pybind11/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ Calculations:
If you clone the repository you have to initialize the submodules with

git submodule init
git submodule update

this will initialize the pybind11 repository for the (optional) python interface
Dependencies:
Expand Down
Binary file modified README.pdf
Binary file not shown.
1 change: 1 addition & 0 deletions README_.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ Calculations:
If you clone the repository you have to initialize the submodules with

git submodule init
git submodule update

this will initialize the pybind11 repository for the (optional) python interface
Dependencies:
Expand Down
4 changes: 2 additions & 2 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#endif

const static char * _info_msg=
"cite as:\nRiccardo Bertossa, analisi\nhttps://github.com/rikigigi/analisi\n(c) 2017-2022\n=========\n"
"cite as:\nRiccardo Bertossa, analisi\nhttps://github.com/rikigigi/analisi\n(c) 2017-2023\n=========\n"
"COMPILED AT " __DATE__ " " __TIME__ " by " CMAKE_CXX_COMPILER " whith flags (Release)"
CMAKE_CXX_FLAGS " " CMAKE_CXX_FLAGS_RELEASE " (Debug) " CMAKE_CXX_FLAGS " " CMAKE_CXX_FLAGS_DEBUG " (build type was " CMAKE_BUILD_TYPE ")"
" on a " CMAKE_SYSTEM " whith processor " CMAKE_SYSTEM_PROCESSOR
Expand All @@ -60,7 +60,7 @@ const static char * _info_msg=
#ifdef XDR_FILE
"\nWith gromacs XDR file conversion support"
#endif
"\nv0.5.0"
"\nv0.5.1"
;


Expand Down
2 changes: 1 addition & 1 deletion install/install_test.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
set -e
pip install pytest pytest-regressions==2.2.0 pandas matplotlib numpy scipy testbook k3d
pip install pytest pytest-regressions pandas matplotlib numpy scipy testbook k3d
4 changes: 2 additions & 2 deletions lib/include/atomicdensity.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class AtomicDensity : public CalculateMultiThread<AtomicDensity<T,Hist>>, public
T * t;
size_t ntypes;
size_t idx(const size_t x, const size_t y, const size_t z, const size_t itype) const {
return x + nbin[2]*(y + nbin[1]*(z + itype*nbin[0]));
return x + nbin[0]*(y + nbin[1]*(z + itype*nbin[2]));
}
size_t idx_(const double * pos, const double * l, bool & ok,int itype) const {
size_t idxs[3];
Expand All @@ -49,7 +49,7 @@ class AtomicDensity : public CalculateMultiThread<AtomicDensity<T,Hist>>, public
}
idxs[icoord] = std::floor(l_*nbin[icoord]);
}
return idx(idxs[2],idxs[1],idxs[0],itype);
return idx(idxs[0],idxs[1],idxs[2],itype);
}

using CalculateMultiThread<This>::ntimesteps;
Expand Down
6 changes: 6 additions & 0 deletions lib/include/buffer_utils.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#ifndef BUFFER_UTILS_H
#define BUFFER_UTILS_H

#include "compiler_types.h"

template <typename T>
bool has_no_stride(const pybind11::buffer_info & buf) {
Expand All @@ -9,3 +13,5 @@ bool has_no_stride(const pybind11::buffer_info & buf) {
}
return true;
}

#endif
7 changes: 6 additions & 1 deletion lib/include/compiler_types.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#ifndef COMPILER_TYPES_H
#define COMPILER_TYPES_H

#if defined(_MSC_VER)
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#endif
#endif

#endif
4 changes: 2 additions & 2 deletions lib/src/atomicdensity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ void AtomicDensity<T,Hist>::reset(const unsigned int numeroTimestepsPerBlocco)
}
template <class T, class Hist>
std::vector<ssize_t> AtomicDensity<T,Hist>::get_shape() const{
return {static_cast<long>(ntypes),static_cast<long>(nbin[0]),static_cast<long>(nbin[1]),static_cast<long>(nbin[2])};
return {static_cast<long>(ntypes),static_cast<long>(nbin[2]),static_cast<long>(nbin[1]),static_cast<long>(nbin[0])};
}
template <class T, class Hist>
std::vector<ssize_t> AtomicDensity<T,Hist>::get_stride() const {
return {static_cast<long>(sizeof (Hist))*static_cast<long>(nbin[0]*nbin[1]*nbin[2]),static_cast<long>(nbin[1]*nbin[2]*sizeof (Hist)),static_cast<long>(nbin[2]*sizeof (Hist)),static_cast<long>(sizeof (Hist))};
return {static_cast<long>(sizeof (Hist))*static_cast<long>(nbin[0]*nbin[1]*nbin[2]),static_cast<long>(nbin[1]*nbin[0]*sizeof (Hist)),static_cast<long>(nbin[0]*sizeof (Hist)),static_cast<long>(sizeof (Hist))};
}

#ifdef BUILD_MMAP
Expand Down
1 change: 1 addition & 0 deletions lib/src/gofrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <fstream>
#include <sstream>
#include "config.h"
#include "mp.h"

template <class TFLOAT,class T> Gofrt<TFLOAT,T>::Gofrt(T *t, TFLOAT rmin, TFLOAT rmax, unsigned int nbin, unsigned int tmax, unsigned int nthreads, unsigned int skip,unsigned int every, bool debug) :
CalculateMultiThread_T {nthreads, skip, t->get_natoms(), every},
Expand Down
12 changes: 12 additions & 0 deletions lib/src/sphericalbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,25 @@ void SphericalBase<lmax,TFLOAT,T>::calc(int timestep,
#include "config.h"
#ifdef BUILD_MMAP
#include "trajectory.h"
template class SphericalBase<2,double,Trajectory>;
template class SphericalBase<3,double,Trajectory>;
template class SphericalBase<4,double,Trajectory>;
template class SphericalBase<5,double,Trajectory>;
template class SphericalBase<6,double,Trajectory>;
template class SphericalBase<7,double,Trajectory>;
template class SphericalBase<8,double,Trajectory>;
template class SphericalBase<9,double,Trajectory>;
template class SphericalBase<10,double,Trajectory>;
#endif
#ifdef PYTHON_SUPPORT
#include "trajectory_numpy.h"
template class SphericalBase<2,double,Trajectory_numpy>;
template class SphericalBase<3,double,Trajectory_numpy>;
template class SphericalBase<4,double,Trajectory_numpy>;
template class SphericalBase<5,double,Trajectory_numpy>;
template class SphericalBase<6,double,Trajectory_numpy>;
template class SphericalBase<7,double,Trajectory_numpy>;
template class SphericalBase<8,double,Trajectory_numpy>;
template class SphericalBase<9,double,Trajectory_numpy>;
template class SphericalBase<10,double,Trajectory_numpy>;
#endif
12 changes: 12 additions & 0 deletions lib/src/steinhardt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,25 @@ void Steinhardt<l,TFLOAT,T>::join_data() {

#ifdef BUILD_MMAP
#include "trajectory.h"
template class Steinhardt<2,double,Trajectory>;
template class Steinhardt<3,double,Trajectory>;
template class Steinhardt<4,double,Trajectory>;
template class Steinhardt<5,double,Trajectory>;
template class Steinhardt<6,double,Trajectory>;
template class Steinhardt<7,double,Trajectory>;
template class Steinhardt<8,double,Trajectory>;
template class Steinhardt<9,double,Trajectory>;
template class Steinhardt<10,double,Trajectory>;
#endif
#ifdef PYTHON_SUPPORT
#include "trajectory_numpy.h"
template class Steinhardt<2,double,Trajectory_numpy>;
template class Steinhardt<3,double,Trajectory_numpy>;
template class Steinhardt<4,double,Trajectory_numpy>;
template class Steinhardt<5,double,Trajectory_numpy>;
template class Steinhardt<6,double,Trajectory_numpy>;
template class Steinhardt<7,double,Trajectory_numpy>;
template class Steinhardt<8,double,Trajectory_numpy>;
template class Steinhardt<9,double,Trajectory_numpy>;
template class Steinhardt<10,double,Trajectory_numpy>;
#endif
135 changes: 135 additions & 0 deletions notebooks/example2.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%load_ext autoreload\n",
"%autoreload 2\n",
"from pyanalisi import *\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Load the binary trajectory in one shot\n",
"\n",
"can be done better if less RAM usage is needed"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"phase_IV=read_lammps_bin('./dump2.8fs.bin',wrap=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"phase_IV.get_array('positions').shape"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plt.plot(phase_IV.get_array('positions')[:,phase_IV.t.get_lammps_type()==1,0][:,:10])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"pl=show_traj(phase_IV,wrap=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"res=multiinspect([phase_IV], plot=True, prefix='phase_IV_nose_',\n",
" inspect_kw={\n",
" 'nthreads':12,\n",
" 'do_sh':False,\n",
" 'plot_st_kw': {\n",
" 'transpose':True,\n",
" 'xmax':.40,\n",
" 'ymax':.70,\n",
" 'single':(1,1),\n",
" 'plt_points':[(0.15818,0.491385,0.05,{'alpha':0.5,'fill':True,'ls':':','color':'blue'}),#fcc\n",
" (0.084052,0.421813,0.05,{'alpha':0.5,'fill':True,'ls':':','color':'green'})#hcp\n",
" ]\n",
" },\n",
" 'compute_steinhardt_kw':{'skip':40},\n",
" \n",
" })"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib notebook"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"steinhardt_movie(phase_IV,skip=20,n_segments=150,\n",
" plt_steinhardt_kw={\n",
" 'transpose':True,\n",
" 'xmax':.40,\n",
" 'ymax':.70,\n",
" 'single':(1,1)},\n",
" compute_steinhardt_kw={'nthreads':12},\n",
" neigh=[(55,3.5**2,0.0),(65,3.5**2,0.0)]\n",
" )"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Loading

0 comments on commit 7b68dad

Please sign in to comment.