├── media ├── docs ├── README.md ├── media │ ├── lineshapes.png │ ├── lineshape_sqe.png │ ├── monte_carlo_grid.png │ ├── pbte_phonon_dos.png │ ├── matematico_favicon.png │ ├── fcc_al_brillouin_zone.png │ ├── gan_pair_distribution.png │ ├── phase_space_spanning.png │ ├── pbte_phonon_dispersions.png │ └── illustration_of_forceconstants.png ├── javascripts │ └── mathjax.js └── program │ ├── dump_dynamical_matrices.md │ ├── phasespace_surface.md │ ├── pack_simulation.md │ ├── refine_structure.md │ ├── README.md │ ├── samples_from_md.md │ └── crystal_structure_info.md ├── tests ├── lineshape │ ├── Makefile │ ├── infile.ucposcar │ ├── infile.forceconstant │ ├── infile.forceconstant_thirdorder │ ├── reference │ │ └── outfile.phonon_self_energy.hdf5 │ └── test_lineshape.py ├── pack_simulation │ ├── infile.meta │ ├── infile.stat │ ├── infile.forces │ ├── infile.ssposcar │ ├── infile.ucposcar │ ├── Makefile │ ├── infile.positions │ ├── reference │ │ └── outfile.sim.hdf5 │ └── test_pack_simulation.py ├── requirements.txt ├── anharmonic_free_energy │ ├── infile.meta │ ├── infile.stat │ ├── infile.forces │ ├── infile.positions │ ├── infile.ssposcar │ ├── infile.ucposcar │ ├── infile.forceconstant │ ├── Makefile │ ├── infile.forceconstant_thirdorder │ ├── reference │ │ └── outfile.anharmonic_free_energy │ └── test_anharmonic_free_energy.py ├── atomic_distribution │ ├── infile.forces │ ├── infile.meta │ ├── infile.stat │ ├── infile.ssposcar │ ├── infile.ucposcar │ ├── infile.positions │ ├── Makefile │ ├── reference │ │ ├── outfile.pair_distribution.hdf5 │ │ ├── outfile.powder_diffraction.hdf5 │ │ ├── outfile.mean_square_displacement.hdf5 │ │ └── outfile.mean_square_displacement │ └── test_atomic_distribution.py ├── generate_structure │ ├── infile.ucposcar │ ├── Makefile │ ├── reference │ │ └── generate_structure.log │ └── test_generate_structure.py ├── thermal_conductivity │ ├── infile.sim.hdf5 │ ├── infile.ssposcar │ ├── infile.ucposcar │ ├── infile.lotosplitting │ ├── Makefile │ ├── test_thermal_conductivity.py │ └── reference │ │ └── outfile.thermal_conductivity ├── canonical_configuration │ ├── infile.ssposcar │ ├── infile.ucposcar │ ├── infile.forceconstant │ ├── Makefile │ ├── test_canonical_configuration.py │ └── reference │ │ └── canonical_configuration.dat ├── crystal_structure_info │ ├── infile.ucposcar │ ├── Makefile │ ├── reference │ │ └── outfile.qpoints_dispersion │ └── test_crystal_structure_info.py ├── extract_forceconstants │ ├── infile.sim.hdf5 │ ├── infile.ssposcar │ ├── infile.ucposcar │ ├── infile.lotosplitting │ ├── Makefile │ └── test_extract_forceconstants.py ├── thermal_conductivity_2023 │ ├── infile.sim.hdf5 │ ├── infile.ssposcar │ ├── infile.ucposcar │ ├── infile.lotosplitting │ ├── .gitignore │ ├── reference │ │ ├── outfile.cumulative_kappa.hdf5 │ │ └── outfile.thermal_conductivity │ ├── Makefile │ └── test_thermal_conductivity_2023.py ├── phonon_dispersion_relations │ ├── infile.ucposcar │ ├── infile.forceconstant │ ├── Makefile │ └── test_dispersion_relations.py ├── dump_dynamical_matrices │ ├── Makefile │ ├── infile.ucposcar │ └── test_dump_dynamical_matrices.py ├── infiles │ ├── infile.sim.hdf5 │ ├── infile.meta │ ├── README.md │ ├── infile.ucposcar │ └── infile.lotosplitting ├── optional │ ├── phasespace_surface │ │ ├── Makefile │ │ ├── 00-ln_files.sh │ │ ├── README.md │ │ ├── 01-run.sh │ │ └── test_phasespace_surface.py │ ├── 00-set_path.sh │ ├── make_all_testfiles.sh │ └── Makefile ├── pytest.ini ├── 00-set_path.sh ├── Makefile ├── make_all_testfiles.sh └── README.md ├── src ├── libolle │ ├── precompilerdefinitions.f90 │ ├── cgal_cleanup.cc │ ├── type_forceconstant_firstorder_io.f90 │ ├── type_forceconstant_firstorder.f90 │ ├── cgal_chull2.cc │ ├── cgal_chull3.cc │ ├── cgal_deltri2.cc │ ├── cgal_deltri3.cc │ ├── type_lennardjones.f90 │ └── precompilerdefinitions ├── refine_structure │ ├── lo_spacegroup_charactertable.f90 │ ├── meson.build │ ├── manual.md │ ├── Makefile │ └── options.f90 ├── libflap │ ├── meson.build │ ├── LICENSE.mit.md │ ├── flap.f90 │ ├── LICENSE.bsd-3.md │ ├── LICENSE.bsd-2.md │ └── Makefile ├── pack_simulation │ ├── meson.build │ ├── manual.md │ └── Makefile ├── samples_from_md │ ├── meson.build │ ├── Makefile │ ├── manual.md │ └── options.f90 ├── crystal_structure_info │ ├── meson.build │ ├── Makefile │ ├── manual.md │ └── options.f90 ├── dump_dynamical_matrices │ ├── meson.build │ ├── Makefile │ └── options.f90 ├── extract_forceconstants │ ├── meson.build │ ├── Makefile │ └── make.log ├── generate_structure │ ├── meson.build │ └── Makefile ├── phasespace_surface │ ├── meson.build │ ├── Makefile │ └── type_phasespacesurface_energycalculations.f90 ├── canonical_configuration │ ├── meson.build │ └── Makefile ├── anharmonic_free_energy │ ├── meson.build │ └── Makefile ├── thermal_conductivity │ ├── meson.build │ ├── Makefile │ └── scattering_isotope.f90 ├── thermal_conductivity_2023 │ ├── meson.build │ └── Makefile ├── atomic_distribution │ ├── meson.build │ └── Makefile ├── phonon_dispersion_relations │ ├── meson.build │ └── Makefile ├── lineshape │ ├── meson.build │ ├── phonondamping_aux.f90 │ └── Makefile └── manual │ ├── workflows │ ├── index.md │ ├── minimal_example_3.md │ ├── minimal_example_5.md │ └── minimal_example_6.md │ ├── index.md │ └── 1_utilities.md ├── .github ├── important_settings.fastcompile ├── important_settings.x86_64_fastcompile ├── important_settings.x86_64_debugflags ├── workflows │ ├── draft-pdf.yml │ └── ci_simple_compilation_and_test.yml ├── ISSUE_TEMPLATE │ └── error.md ├── important_settings.generic └── important_settings.x86_64 ├── examples ├── example_1_fcc_al │ ├── infile.meta │ ├── Makefile │ └── infile.ucposcar └── build │ ├── important_settings.dardel │ ├── important_settings.sigma │ ├── important_settings.tetralith │ ├── important_settings.gfortran │ ├── important_settings.apple_silicon_gfortran12 │ ├── important_settings.conda │ ├── important_settings.tetralith.cgal │ ├── important_settings.cgal │ ├── important_settings.marenostrum5 │ └── important_settings.osx_gfortran_accelerate ├── setup_git_version.sh ├── paper └── Makefile ├── LICENSE.md ├── meson.build ├── CONTRIBUTING.md ├── .gitignore ├── mkdocs.yml └── CITATION.cff /media: -------------------------------------------------------------------------------- 1 | docs/media/ -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | ../README.md -------------------------------------------------------------------------------- /tests/lineshape/Makefile: -------------------------------------------------------------------------------- 1 | testfiles: 2 | lineshape 3 | -------------------------------------------------------------------------------- /tests/lineshape/infile.ucposcar: -------------------------------------------------------------------------------- 1 | ../infiles/infile.ucposcar -------------------------------------------------------------------------------- /tests/pack_simulation/infile.meta: -------------------------------------------------------------------------------- 1 | ../infiles/infile.meta -------------------------------------------------------------------------------- /tests/pack_simulation/infile.stat: -------------------------------------------------------------------------------- 1 | ../infiles/infile.stat -------------------------------------------------------------------------------- /tests/requirements.txt: -------------------------------------------------------------------------------- 1 | numpy 2 | xarray[io] 3 | pytest 4 | -------------------------------------------------------------------------------- /src/libolle/precompilerdefinitions.f90: -------------------------------------------------------------------------------- 1 | precompilerdefinitions -------------------------------------------------------------------------------- /tests/anharmonic_free_energy/infile.meta: -------------------------------------------------------------------------------- 1 | ../infiles/infile.meta -------------------------------------------------------------------------------- /tests/anharmonic_free_energy/infile.stat: -------------------------------------------------------------------------------- 1 | ../infiles/infile.stat -------------------------------------------------------------------------------- /tests/atomic_distribution/infile.forces: -------------------------------------------------------------------------------- 1 | ../infiles/infile.forces -------------------------------------------------------------------------------- /tests/atomic_distribution/infile.meta: -------------------------------------------------------------------------------- 1 | ../infiles/infile.meta -------------------------------------------------------------------------------- /tests/atomic_distribution/infile.stat: -------------------------------------------------------------------------------- 1 | ../infiles/infile.stat -------------------------------------------------------------------------------- /tests/pack_simulation/infile.forces: -------------------------------------------------------------------------------- 1 | ../infiles/infile.forces -------------------------------------------------------------------------------- /tests/pack_simulation/infile.ssposcar: -------------------------------------------------------------------------------- 1 | ../infiles/infile.ssposcar -------------------------------------------------------------------------------- /tests/pack_simulation/infile.ucposcar: -------------------------------------------------------------------------------- 1 | ../infiles/infile.ucposcar -------------------------------------------------------------------------------- /.github/important_settings.fastcompile: -------------------------------------------------------------------------------- 1 | OPTIMIZATION_LEVEL="-O0" 2 | -------------------------------------------------------------------------------- /tests/anharmonic_free_energy/infile.forces: -------------------------------------------------------------------------------- 1 | ../infiles/infile.forces -------------------------------------------------------------------------------- /tests/atomic_distribution/infile.ssposcar: -------------------------------------------------------------------------------- 1 | ../infiles/infile.ssposcar -------------------------------------------------------------------------------- /tests/atomic_distribution/infile.ucposcar: -------------------------------------------------------------------------------- 1 | ../infiles/infile.ucposcar -------------------------------------------------------------------------------- /tests/generate_structure/infile.ucposcar: -------------------------------------------------------------------------------- 1 | ../infiles/infile.ucposcar -------------------------------------------------------------------------------- /tests/lineshape/infile.forceconstant: -------------------------------------------------------------------------------- 1 | ../infiles/infile.forceconstant -------------------------------------------------------------------------------- /tests/pack_simulation/Makefile: -------------------------------------------------------------------------------- 1 | testfiles: 2 | pack_simulation 3 | -------------------------------------------------------------------------------- /tests/pack_simulation/infile.positions: -------------------------------------------------------------------------------- 1 | ../infiles/infile.positions -------------------------------------------------------------------------------- /tests/thermal_conductivity/infile.sim.hdf5: -------------------------------------------------------------------------------- 1 | ../infiles/infile.sim.hdf5 -------------------------------------------------------------------------------- /tests/thermal_conductivity/infile.ssposcar: -------------------------------------------------------------------------------- 1 | ../infiles/infile.ssposcar -------------------------------------------------------------------------------- /tests/thermal_conductivity/infile.ucposcar: -------------------------------------------------------------------------------- 1 | ../infiles/infile.ucposcar -------------------------------------------------------------------------------- /tests/anharmonic_free_energy/infile.positions: -------------------------------------------------------------------------------- 1 | ../infiles/infile.positions -------------------------------------------------------------------------------- /tests/anharmonic_free_energy/infile.ssposcar: -------------------------------------------------------------------------------- 1 | ../infiles/infile.ssposcar -------------------------------------------------------------------------------- /tests/anharmonic_free_energy/infile.ucposcar: -------------------------------------------------------------------------------- 1 | ../infiles/infile.ucposcar -------------------------------------------------------------------------------- /tests/atomic_distribution/infile.positions: -------------------------------------------------------------------------------- 1 | ../infiles/infile.positions -------------------------------------------------------------------------------- /tests/canonical_configuration/infile.ssposcar: -------------------------------------------------------------------------------- 1 | ../infiles/infile.ucposcar -------------------------------------------------------------------------------- /tests/canonical_configuration/infile.ucposcar: -------------------------------------------------------------------------------- 1 | ../infiles/infile.ucposcar -------------------------------------------------------------------------------- /tests/crystal_structure_info/infile.ucposcar: -------------------------------------------------------------------------------- 1 | ../infiles/infile.ucposcar -------------------------------------------------------------------------------- /tests/extract_forceconstants/infile.sim.hdf5: -------------------------------------------------------------------------------- 1 | ../infiles/infile.sim.hdf5 -------------------------------------------------------------------------------- /tests/extract_forceconstants/infile.ssposcar: -------------------------------------------------------------------------------- 1 | ../infiles/infile.ssposcar -------------------------------------------------------------------------------- /tests/extract_forceconstants/infile.ucposcar: -------------------------------------------------------------------------------- 1 | ../infiles/infile.ucposcar -------------------------------------------------------------------------------- /tests/thermal_conductivity_2023/infile.sim.hdf5: -------------------------------------------------------------------------------- 1 | ../infiles/infile.sim.hdf5 -------------------------------------------------------------------------------- /tests/thermal_conductivity_2023/infile.ssposcar: -------------------------------------------------------------------------------- 1 | ../infiles/infile.ssposcar -------------------------------------------------------------------------------- /tests/thermal_conductivity_2023/infile.ucposcar: -------------------------------------------------------------------------------- 1 | ../infiles/infile.ucposcar -------------------------------------------------------------------------------- /.github/important_settings.x86_64_fastcompile: -------------------------------------------------------------------------------- 1 | OPTIMIZATION_LEVEL="-O0" 2 | -------------------------------------------------------------------------------- /tests/phonon_dispersion_relations/infile.ucposcar: -------------------------------------------------------------------------------- 1 | ../infiles/infile.ucposcar -------------------------------------------------------------------------------- /tests/thermal_conductivity/infile.lotosplitting: -------------------------------------------------------------------------------- 1 | ../infiles/infile.lotosplitting -------------------------------------------------------------------------------- /tests/anharmonic_free_energy/infile.forceconstant: -------------------------------------------------------------------------------- 1 | ../infiles/infile.forceconstant -------------------------------------------------------------------------------- /tests/canonical_configuration/infile.forceconstant: -------------------------------------------------------------------------------- 1 | ../infiles/infile.forceconstant -------------------------------------------------------------------------------- /tests/extract_forceconstants/infile.lotosplitting: -------------------------------------------------------------------------------- 1 | ../infiles/infile.lotosplitting -------------------------------------------------------------------------------- /tests/thermal_conductivity_2023/infile.lotosplitting: -------------------------------------------------------------------------------- 1 | ../infiles/infile.lotosplitting -------------------------------------------------------------------------------- /tests/phonon_dispersion_relations/infile.forceconstant: -------------------------------------------------------------------------------- 1 | ../infiles/infile.forceconstant -------------------------------------------------------------------------------- /tests/dump_dynamical_matrices/Makefile: -------------------------------------------------------------------------------- 1 | testfiles: 2 | dump_dynamical_matrices -qg 3 3 3 3 | -------------------------------------------------------------------------------- /tests/lineshape/infile.forceconstant_thirdorder: -------------------------------------------------------------------------------- 1 | ../infiles/infile.forceconstant_thirdorder -------------------------------------------------------------------------------- /tests/phonon_dispersion_relations/Makefile: -------------------------------------------------------------------------------- 1 | testfiles: 2 | phonon_dispersion_relations 3 | -------------------------------------------------------------------------------- /tests/atomic_distribution/Makefile: -------------------------------------------------------------------------------- 1 | testfiles: 2 | rm -f outfile.* 3 | atomic_distribution 4 | -------------------------------------------------------------------------------- /tests/anharmonic_free_energy/Makefile: -------------------------------------------------------------------------------- 1 | testfiles: 2 | anharmonic_free_energy --thirdorder -qg 4 4 4 3 | -------------------------------------------------------------------------------- /tests/anharmonic_free_energy/infile.forceconstant_thirdorder: -------------------------------------------------------------------------------- 1 | ../infiles/infile.forceconstant_thirdorder -------------------------------------------------------------------------------- /tests/extract_forceconstants/Makefile: -------------------------------------------------------------------------------- 1 | testfiles: 2 | extract_forceconstants -rc2 0 -rc3 0 --polar 3 | -------------------------------------------------------------------------------- /tests/thermal_conductivity_2023/.gitignore: -------------------------------------------------------------------------------- 1 | infile.forceconstant 2 | infile.forceconstant_thirdorder 3 | -------------------------------------------------------------------------------- /docs/media/lineshapes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdep-developers/tdep/HEAD/docs/media/lineshapes.png -------------------------------------------------------------------------------- /docs/media/lineshape_sqe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdep-developers/tdep/HEAD/docs/media/lineshape_sqe.png -------------------------------------------------------------------------------- /tests/generate_structure/Makefile: -------------------------------------------------------------------------------- 1 | testfiles: 2 | generate_structure -na 200 | tee generate_structure.log 3 | -------------------------------------------------------------------------------- /docs/media/monte_carlo_grid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdep-developers/tdep/HEAD/docs/media/monte_carlo_grid.png -------------------------------------------------------------------------------- /docs/media/pbte_phonon_dos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdep-developers/tdep/HEAD/docs/media/pbte_phonon_dos.png -------------------------------------------------------------------------------- /tests/crystal_structure_info/Makefile: -------------------------------------------------------------------------------- 1 | testfiles: 2 | crystal_structure_info 3 | 4 | test: testfiles 5 | pytest 6 | -------------------------------------------------------------------------------- /tests/infiles/infile.sim.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdep-developers/tdep/HEAD/tests/infiles/infile.sim.hdf5 -------------------------------------------------------------------------------- /docs/media/matematico_favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdep-developers/tdep/HEAD/docs/media/matematico_favicon.png -------------------------------------------------------------------------------- /docs/media/fcc_al_brillouin_zone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdep-developers/tdep/HEAD/docs/media/fcc_al_brillouin_zone.png -------------------------------------------------------------------------------- /docs/media/gan_pair_distribution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdep-developers/tdep/HEAD/docs/media/gan_pair_distribution.png -------------------------------------------------------------------------------- /docs/media/phase_space_spanning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdep-developers/tdep/HEAD/docs/media/phase_space_spanning.png -------------------------------------------------------------------------------- /docs/media/pbte_phonon_dispersions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdep-developers/tdep/HEAD/docs/media/pbte_phonon_dispersions.png -------------------------------------------------------------------------------- /docs/media/illustration_of_forceconstants.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdep-developers/tdep/HEAD/docs/media/illustration_of_forceconstants.png -------------------------------------------------------------------------------- /examples/example_1_fcc_al/infile.meta: -------------------------------------------------------------------------------- 1 | 125 #natoms 2 | 141 #ionsteps 3 | 1.0 #timestep 4 | 500 #temperature of thermostat 5 | 6 | -------------------------------------------------------------------------------- /tests/optional/phasespace_surface/Makefile: -------------------------------------------------------------------------------- 1 | testfiles: 2 | bash 01-run.sh 3 | 4 | clean: 5 | rm -f *.log 6 | rm -f infile.* 7 | rm -r __pycache__ 8 | -------------------------------------------------------------------------------- /tests/pack_simulation/reference/outfile.sim.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdep-developers/tdep/HEAD/tests/pack_simulation/reference/outfile.sim.hdf5 -------------------------------------------------------------------------------- /tests/pytest.ini: -------------------------------------------------------------------------------- 1 | # pytest.ini or .pytest.ini 2 | [pytest] 3 | norecursedirs = optional 4 | filterwarnings = 5 | ignore::RuntimeWarning:importlib._bootstrap: 6 | -------------------------------------------------------------------------------- /tests/lineshape/reference/outfile.phonon_self_energy.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdep-developers/tdep/HEAD/tests/lineshape/reference/outfile.phonon_self_energy.hdf5 -------------------------------------------------------------------------------- /tests/atomic_distribution/reference/outfile.pair_distribution.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdep-developers/tdep/HEAD/tests/atomic_distribution/reference/outfile.pair_distribution.hdf5 -------------------------------------------------------------------------------- /tests/atomic_distribution/reference/outfile.powder_diffraction.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdep-developers/tdep/HEAD/tests/atomic_distribution/reference/outfile.powder_diffraction.hdf5 -------------------------------------------------------------------------------- /tests/canonical_configuration/Makefile: -------------------------------------------------------------------------------- 1 | testfiles: 2 | canonical_configuration --modes | tail -n 12 | tee canonical_configuration.dat 3 | rm contcar* 4 | 5 | test: testfiles 6 | pytest 7 | -------------------------------------------------------------------------------- /tests/optional/phasespace_surface/00-ln_files.sh: -------------------------------------------------------------------------------- 1 | ln -sf ../../infiles/infile.ucposcar 2 | ln -sf ../../infiles/infile.forceconstant 3 | ln -sf ../../infiles/infile.forceconstant_thirdorder 4 | -------------------------------------------------------------------------------- /tests/thermal_conductivity_2023/reference/outfile.cumulative_kappa.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdep-developers/tdep/HEAD/tests/thermal_conductivity_2023/reference/outfile.cumulative_kappa.hdf5 -------------------------------------------------------------------------------- /src/refine_structure/lo_spacegroup_charactertable.f90: -------------------------------------------------------------------------------- 1 | submodule(lo_spacegroup) lo_spacegroup_charactertable 2 | !! Generates symmetry operations 3 | implicit none 4 | contains 5 | 6 | end submodule 7 | -------------------------------------------------------------------------------- /tests/atomic_distribution/reference/outfile.mean_square_displacement.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdep-developers/tdep/HEAD/tests/atomic_distribution/reference/outfile.mean_square_displacement.hdf5 -------------------------------------------------------------------------------- /tests/00-set_path.sh: -------------------------------------------------------------------------------- 1 | source ../bashrc_tdep 2 | 3 | export PATH="$TDEP_BIN_DIR:$PATH" 4 | 5 | echo "... binary directory for testing: $TDEP_BIN_DIR" 6 | echo "... set PATH: ${PATH}" 7 | -------------------------------------------------------------------------------- /tests/infiles/infile.meta: -------------------------------------------------------------------------------- 1 | 216 # N atoms 2 | 24 # N timesteps 3 | 1.0 # timestep in fs (currently not used ) 4 | -314.1592 # temperature in K (currently not used) 5 | -------------------------------------------------------------------------------- /tests/optional/00-set_path.sh: -------------------------------------------------------------------------------- 1 | source ../../bashrc_tdep 2 | 3 | export PATH="$TDEP_BIN_DIR:$PATH" 4 | 5 | echo "... binary directory for testing: $TDEP_BIN_DIR" 6 | echo "... set PATH: ${PATH}" 7 | -------------------------------------------------------------------------------- /tests/infiles/README.md: -------------------------------------------------------------------------------- 1 | Test files 2 | === 3 | 4 | Forceconstants for testing were created with 5 | 6 | ```bash 7 | extract_forceconstants -rc2 0 -rc3 --polar 8 | ``` 9 | 10 | from TDEP commit `8c01e0343e4098f1d160efc141f8af6ae7f54941`. -------------------------------------------------------------------------------- /tests/optional/phasespace_surface/README.md: -------------------------------------------------------------------------------- 1 | There is a lot of degeneracy in the modes, we therefore allow for some deviation from the reference values. The number should be qualitatively the same. 2 | 3 | The reference data was generated with gfortran-13, O3 4 | -------------------------------------------------------------------------------- /examples/example_1_fcc_al/Makefile: -------------------------------------------------------------------------------- 1 | test: 2 | extract_forceconstants -rc2 3 -rc3 2 3 | ln -sf outfile.forceconstant infile.forceconstant 4 | ln -sf outfile.forceconstant_thirdorder infile.forceconstant_thirdorder 5 | mpirun phonon_dispersion_relations --dos -p 6 | 7 | -------------------------------------------------------------------------------- /src/libolle/cgal_cleanup.cc: -------------------------------------------------------------------------------- 1 | 2 | // these should be in a generic interface. I wonder what that is called in c++ 3 | extern "C"{ void lo_cgal_cleanup_int_pointer(int *&A){ delete A; }} 4 | extern "C"{ void lo_cgal_cleanup_double_pointer(double *&A){ delete A; }} 5 | 6 | -------------------------------------------------------------------------------- /examples/example_1_fcc_al/infile.ucposcar: -------------------------------------------------------------------------------- 1 | kommentar 2 | 4.047266 3 | 0.000000000 0.500000000 0.500000000 4 | 0.500000000 0.000000000 0.500000000 5 | 0.500000000 0.500000000 0.000000000 6 | Al 7 | 1 8 | direct coordinates 9 | 0.000000000 0.000000000 0.000000000 site: 1 10 | -------------------------------------------------------------------------------- /tests/optional/phasespace_surface/01-run.sh: -------------------------------------------------------------------------------- 1 | source 00-ln_files.sh 2 | 3 | phasespace_surface \ 4 | --verbose \ 5 | --qpoint_grid 11 11 11 \ 6 | --qpoint 0.0 0.0 1E-4 \ 7 | --intensities \ 8 | | tee phasespace_surface.log 9 | # --povray \ 10 | -------------------------------------------------------------------------------- /tests/optional/make_all_testfiles.sh: -------------------------------------------------------------------------------- 1 | folders=" 2 | phasespace_surface/ 3 | " 4 | 5 | echo "RUN TESTS" 6 | 7 | source 00-set_path.sh 8 | 9 | for folder in ${folders} 10 | do 11 | echo "RUN ${folder}" 12 | pushd $folder 13 | make testfiles 14 | popd 15 | echo 16 | done 17 | -------------------------------------------------------------------------------- /tests/Makefile: -------------------------------------------------------------------------------- 1 | testfiles: 2 | bash make_all_testfiles.sh 3 | 4 | test: 5 | pytest 6 | 7 | all: clean testfiles 8 | pytest 9 | 10 | clean: 11 | rm -f */outfile* 12 | rm -rf */__pycache__/ 13 | rm -rf *.pytest_cache/ 14 | rm -f */contcar* 15 | rm -f */*.dat 16 | rm -f */*.log 17 | 18 | -------------------------------------------------------------------------------- /tests/optional/Makefile: -------------------------------------------------------------------------------- 1 | testfiles: 2 | bash make_all_testfiles.sh 3 | 4 | test: 5 | pytest 6 | 7 | all: clean testfiles 8 | pytest 9 | 10 | clean: 11 | rm -f */outfile* 12 | rm -rf */__pycache__/ 13 | rm -rf *.pytest_cache/ 14 | rm -f */contcar* 15 | rm -f */*.dat 16 | rm -f */*.log 17 | 18 | -------------------------------------------------------------------------------- /tests/anharmonic_free_energy/reference/outfile.anharmonic_free_energy: -------------------------------------------------------------------------------- 1 | # Free energy at -314.16 K, unit : eV/atom 2 | # Lowest order (1st order cumulant, 2nd order cumulant) 3 | -3744.84683 -3744.84683 4 | # Third order anharmonic corrections (1st order cumulant, 2nd order cumulant) 5 | -3744.84770 -3744.84770 6 | -------------------------------------------------------------------------------- /setup_git_version.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env sh 2 | 3 | # It is to be used with the MEson build system. There is no need to run it when 4 | # using the ./build_things.sh script. 5 | 6 | cd src/libolle 7 | cat>gitinformation< { 18 | MathJax.typesetPromise() 19 | }) 20 | 21 | -------------------------------------------------------------------------------- /src/crystal_structure_info/meson.build: -------------------------------------------------------------------------------- 1 | executable('crystal_structure_info', 2 | 'main.f90', 3 | 'options.f90', 4 | link_with: [libolle, libflap], 5 | include_directories: ['../libolle', '../libflap'], 6 | dependencies: dep_all, 7 | install: true, 8 | install_dir: meson.project_build_root() / 'bin') 9 | 10 | install_symlink('crystal_structure_info', pointing_to: meson.project_build_root() / 'bin/crystal_structure_info', install_dir: meson.project_source_root() / 'bin') 11 | -------------------------------------------------------------------------------- /src/dump_dynamical_matrices/meson.build: -------------------------------------------------------------------------------- 1 | executable('dump_dynamical_matrices', 2 | 'main.f90', 3 | 'options.f90', 4 | link_with: [libolle, libflap], 5 | include_directories: ['../libolle', '../libflap'], 6 | dependencies: dep_all, 7 | install: true, 8 | install_dir: meson.project_build_root() / 'bin') 9 | 10 | install_symlink('dump_dynamical_matrices', pointing_to: meson.project_build_root() / 'bin/dump_dynamical_matrices', install_dir: meson.project_source_root() / 'bin') 11 | -------------------------------------------------------------------------------- /src/extract_forceconstants/meson.build: -------------------------------------------------------------------------------- 1 | executable('extract_forceconstants', 2 | 'main.f90', 3 | 'options.f90', 4 | link_with: [libolle, libflap], 5 | include_directories: ['../libolle', '../libflap'], 6 | dependencies: dep_all, 7 | install: true, 8 | install_dir: meson.project_build_root() / 'bin') 9 | 10 | install_symlink('extract_forceconstants', pointing_to: meson.project_build_root() / 'bin/extract_forceconstants', install_dir: meson.project_source_root() / 'bin') 11 | -------------------------------------------------------------------------------- /tests/make_all_testfiles.sh: -------------------------------------------------------------------------------- 1 | folders="anharmonic_free_energy/ 2 | atomic_distribution/ 3 | canonical_configuration/ 4 | crystal_structure_info/ 5 | dump_dynamical_matrices/ 6 | extract_forceconstants/ 7 | generate_structure/ 8 | lineshape/ 9 | pack_simulation/ 10 | phonon_dispersion_relations/ 11 | thermal_conductivity_2023/ 12 | thermal_conductivity/ 13 | " 14 | 15 | echo "RUN TESTS" 16 | 17 | source 00-set_path.sh 18 | 19 | for folder in ${folders} 20 | do 21 | echo "RUN ${folder}" 22 | pushd $folder 23 | make testfiles 24 | popd 25 | echo 26 | done 27 | -------------------------------------------------------------------------------- /src/generate_structure/meson.build: -------------------------------------------------------------------------------- 1 | executable('generate_structure', 2 | 'autocell.f90', 3 | 'main.f90', 4 | 'options.f90', 5 | link_with: [libolle, libflap], 6 | include_directories: ['../libolle', '../libflap'], 7 | dependencies: dep_all, 8 | install: true, 9 | install_dir: meson.project_build_root() / 'bin') 10 | 11 | install_symlink('generate_structure', pointing_to: meson.project_build_root() / 'bin/generate_structure', install_dir: meson.project_source_root() / 'bin') 12 | -------------------------------------------------------------------------------- /tests/phonon_dispersion_relations/test_dispersion_relations.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pathlib import Path 3 | 4 | parent = Path(__file__).parent 5 | folder = parent / "reference" 6 | 7 | 8 | def test_dispersion(file="outfile.dispersion_relations"): 9 | file_ref = folder / file 10 | file_new = parent / file 11 | 12 | data_ref = np.loadtxt(file_ref) 13 | data_new = np.loadtxt(file_new) 14 | 15 | np.testing.assert_allclose(data_ref, data_new, err_msg=file_new.absolute()) 16 | 17 | 18 | if __name__ == "__main__": 19 | test_dispersion() 20 | -------------------------------------------------------------------------------- /src/phasespace_surface/meson.build: -------------------------------------------------------------------------------- 1 | executable('phasespace_surface', 2 | 'main.f90', 3 | 'options.f90', 4 | 'type_phasespacesurface.f90', 5 | link_with: [libolle, libflap], 6 | include_directories: ['../libolle', '../libflap'], 7 | dependencies: dep_all, 8 | install: true, 9 | install_dir: meson.project_build_root() / 'bin') 10 | 11 | install_symlink('phasespace_surface', pointing_to: meson.project_build_root() / 'bin/phasespace_surface', install_dir: meson.project_source_root() / 'bin') 12 | -------------------------------------------------------------------------------- /src/canonical_configuration/meson.build: -------------------------------------------------------------------------------- 1 | executable('canonical_configuration', 2 | 'main.f90', 3 | 'options.f90', 4 | 'semirandom.f90', 5 | link_with: [libolle, libflap], 6 | include_directories: ['../libolle', '../libflap'], 7 | dependencies: dep_all, 8 | install: true, 9 | install_dir: meson.project_build_root() / 'bin') 10 | 11 | install_symlink('canonical_configuration', pointing_to: meson.project_build_root() / 'bin/canonical_configuration', install_dir: meson.project_source_root() / 'bin') 12 | -------------------------------------------------------------------------------- /tests/anharmonic_free_energy/test_anharmonic_free_energy.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pathlib import Path 3 | 4 | parent = Path(__file__).parent 5 | folder = parent / "reference" 6 | 7 | 8 | def _read_file(file): 9 | data = np.loadtxt(file) 10 | return data 11 | 12 | 13 | def test_output(file="outfile.anharmonic_free_energy"): 14 | data_ref = _read_file(folder / file) 15 | data_new = _read_file(parent / file) 16 | 17 | np.testing.assert_allclose(data_ref, data_new, err_msg=(parent / file).absolute()) 18 | 19 | 20 | if __name__ == "__main__": 21 | test_output() 22 | -------------------------------------------------------------------------------- /src/anharmonic_free_energy/meson.build: -------------------------------------------------------------------------------- 1 | executable('anharmonic_free_energy', 2 | 'energy.f90', 3 | 'epot.f90', 4 | 'main.f90', 5 | 'options.f90', 6 | link_with: [libolle, libflap], 7 | include_directories: ['../libolle', '../libflap'], 8 | dependencies: dep_all, 9 | install: true, 10 | install_dir: meson.project_build_root() / 'bin') 11 | 12 | install_symlink('anharmonic_free_energy', pointing_to: meson.project_build_root() / 'bin/anharmonic_free_energy', install_dir: meson.project_source_root() / 'bin') 13 | -------------------------------------------------------------------------------- /src/thermal_conductivity/meson.build: -------------------------------------------------------------------------------- 1 | executable('thermal_conductivity', 2 | 'cumulative_kappa.f90', 3 | 'kappa.f90', 4 | 'main.f90', 5 | 'options.f90', 6 | 'scattering.f90', 7 | link_with: [libolle, libflap], 8 | include_directories: ['../libolle', '../libflap'], 9 | dependencies: dep_all, 10 | install: true, 11 | install_dir: meson.project_build_root() / 'bin') 12 | 13 | install_symlink('thermal_conductivity', pointing_to: meson.project_build_root() / 'bin/thermal_conductivity', install_dir: meson.project_source_root() / 'bin') 14 | -------------------------------------------------------------------------------- /tests/generate_structure/test_generate_structure.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pathlib import Path 3 | 4 | parent = Path(__file__).parent 5 | folder = parent / "reference" 6 | 7 | 8 | def _read_log(file): 9 | """Return number of atoms only""" 10 | natoms = int(open(file).readlines()[9].split()[3]) 11 | return natoms 12 | 13 | 14 | def test_log(file="generate_structure.log"): 15 | data_ref = _read_log(folder / file) 16 | data_new = _read_log(parent / file) 17 | 18 | np.testing.assert_allclose(data_ref, data_new, err_msg=(parent / file).absolute()) 19 | 20 | 21 | if __name__ == "__main__": 22 | test_log() 23 | -------------------------------------------------------------------------------- /tests/dump_dynamical_matrices/test_dump_dynamical_matrices.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pathlib import Path 3 | 4 | parent = Path(__file__).parent 5 | folder = parent / "reference" 6 | 7 | 8 | def test_dispersion(file="outfile.many_dynamical_matrices_DDB"): 9 | file_ref = folder / file 10 | file_new = parent / file 11 | 12 | data_ref = np.loadtxt(file_ref, skiprows=151, comments=["q", "2n"]) 13 | data_new = np.loadtxt(file_new, skiprows=151, comments=["q", "2n"]) 14 | 15 | np.testing.assert_allclose(data_ref, data_new, err_msg=file_new.absolute()) 16 | print("all done and all close") 17 | 18 | 19 | if __name__ == "__main__": 20 | test_dispersion() 21 | -------------------------------------------------------------------------------- /src/thermal_conductivity_2023/meson.build: -------------------------------------------------------------------------------- 1 | executable('thermal_conductivity_2023', 2 | 'main.f90', 3 | 'mfp.f90', 4 | 'options.f90', 5 | 'pbe.f90', 6 | 'phononevents.f90', 7 | 'scatteringstrengths.f90', 8 | link_with: [libolle, libflap], 9 | include_directories: ['../libolle', '../libflap'], 10 | dependencies: dep_all, 11 | install: true, 12 | install_dir: meson.project_build_root() / 'bin') 13 | 14 | install_symlink('thermal_conductivity_2023', pointing_to: meson.project_build_root() / 'bin/thermal_conductivity_2023', install_dir: meson.project_source_root() / 'bin') 15 | -------------------------------------------------------------------------------- /.github/important_settings.x86_64_debugflags: -------------------------------------------------------------------------------- 1 | # debug flags 2 | # FCFLAGS_EXTRA="-g -fbacktrace -fcheck=all -finit-real=nan -finit-derived -fmax-errors=10 --pedantic -Wall -Wextra -pedantic -Wcast-align -Wdisabled-optimization -Wmissing-include-dirs -Wshadow -Wunused -fdiagnostics-show-option -fcheck=all -Wstrict-overflow=0 -Wrealloc-lhs" 3 | # FCFLAGS_EXTRA="-fbacktrace -fcheck=all -finit-real=nan -finit-derived -fmax-errors=10 --pedantic --warn-all" 4 | FCFLAGS_EXTRA="-fbacktrace -finit-real=nan -finit-derived -fmax-errors=10 --pedantic --warn-all" 5 | # PRECOMPILER_FLAGS="-DGP${GNUPLOTTERMINAL} -Dclusterprogressbar -DAGRESSIVE_SANITY" 6 | PRECOMPILER_FLAGS="-DGP${GNUPLOTTERMINAL} -Dclusterprogressbar" 7 | OPTIMIZATION_LEVEL="-O0" 8 | -------------------------------------------------------------------------------- /tests/pack_simulation/test_pack_simulation.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import xarray as xr 3 | from pathlib import Path 4 | 5 | parent = Path(__file__).parent 6 | folder = parent / "reference" 7 | 8 | files_hdf5 = [ 9 | "outfile.sim.hdf5", 10 | ] 11 | 12 | 13 | def test_hdf5(files=files_hdf5): 14 | for file in files: 15 | file_ref = folder / file 16 | file_new = parent / file 17 | 18 | ds_ref = xr.load_dataset(file_ref) 19 | ds_new = xr.load_dataset(file_new) 20 | 21 | for var in ds_ref.data_vars: 22 | x = ds_ref[var] 23 | y = ds_new[var] 24 | np.testing.assert_allclose(x, y, err_msg=var) 25 | 26 | 27 | if __name__ == "__main__": 28 | test_hdf5() 29 | -------------------------------------------------------------------------------- /tests/lineshape/test_lineshape.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import xarray as xr 3 | from pathlib import Path 4 | 5 | parent = Path(__file__).parent 6 | folder = parent / "reference" 7 | 8 | files_hdf5 = [ 9 | "outfile.phonon_self_energy.hdf5", 10 | ] 11 | 12 | 13 | def test_hdf5(files=files_hdf5): 14 | for file in files: 15 | file_ref = folder / file 16 | file_new = parent / file 17 | 18 | ds_ref = xr.load_dataset(file_ref) 19 | ds_new = xr.load_dataset(file_new) 20 | 21 | for var in ds_ref.data_vars: 22 | x = ds_ref[var] 23 | y = ds_new[var] 24 | np.testing.assert_allclose(x, y, err_msg=var) 25 | 26 | 27 | if __name__ == "__main__": 28 | test_hdf5() 29 | -------------------------------------------------------------------------------- /src/atomic_distribution/meson.build: -------------------------------------------------------------------------------- 1 | executable('atomic_distribution', 2 | 'correlationfunction.f90', 3 | 'diffraction.f90', 4 | 'main.f90', 5 | 'mean_square_displacement.f90', 6 | 'options.f90', 7 | 'pair_distribution.f90', 8 | 'pairmapping.f90', 9 | 'vectordist.f90', 10 | link_with: [libolle, libflap], 11 | include_directories: ['../libolle', '../libflap'], 12 | dependencies: dep_all, 13 | install: true, 14 | install_dir: meson.project_build_root() / 'bin') 15 | 16 | install_symlink('atomic_distribution', pointing_to: meson.project_build_root() / 'bin/atomic_distribution', install_dir: meson.project_source_root() / 'bin') 17 | -------------------------------------------------------------------------------- /src/refine_structure/meson.build: -------------------------------------------------------------------------------- 1 | executable('refine_structure', 2 | 'lo_spacegroup_applyoperation.f90', 3 | 'lo_spacegroup_charactertable.f90', 4 | 'lo_spacegroup.f90', 5 | 'lo_spacegroup_genoperations.f90', 6 | 'lo_spacegroup_helpers.f90', 7 | 'main.f90', 8 | 'options.f90', 9 | 'refine.f90', 10 | link_with: [libolle, libflap], 11 | include_directories: ['../libolle', '../libflap'], 12 | dependencies: dep_all, 13 | install: true, 14 | install_dir: meson.project_build_root() / 'bin') 15 | 16 | install_symlink('refine_structure', pointing_to: meson.project_build_root() / 'bin/refine_structure', install_dir: meson.project_source_root() / 'bin') 17 | -------------------------------------------------------------------------------- /src/phonon_dispersion_relations/meson.build: -------------------------------------------------------------------------------- 1 | executable('phonon_dispersion_relations', 2 | 'activity.f90', 3 | 'densityplots.f90', 4 | 'densityplots_stuntscattering.f90', 5 | 'main.f90', 6 | 'options.f90', 7 | 'type_fast_interpolation.f90', 8 | 'unfold_phonons.f90', 9 | 'velocitydos.f90', 10 | link_with: [libolle, libflap], 11 | include_directories: ['../libolle', '../libflap'], 12 | dependencies: dep_all, 13 | install: true, 14 | install_dir: meson.project_build_root() / 'bin') 15 | 16 | install_symlink('phonon_dispersion_relations', pointing_to: meson.project_build_root() / 'bin/phonon_dispersion_relations', install_dir: meson.project_source_root() / 'bin') 17 | -------------------------------------------------------------------------------- /.github/workflows/draft-pdf.yml: -------------------------------------------------------------------------------- 1 | name: Draft PDF 2 | on: 3 | push: 4 | paths: 5 | - paper/** 6 | 7 | jobs: 8 | paper: 9 | runs-on: ubuntu-latest 10 | name: Paper Draft 11 | steps: 12 | - name: Checkout 13 | uses: actions/checkout@v4 14 | - name: Build draft PDF 15 | uses: openjournals/openjournals-draft-action@master 16 | with: 17 | journal: joss 18 | # This should be the path to the paper within your repo. 19 | paper-path: paper/paper.md 20 | - name: Upload 21 | uses: actions/upload-artifact@v4 22 | with: 23 | name: paper 24 | # This is the output path where Pandoc will write the compiled 25 | # PDF. Note, this should be the same directory as the input 26 | # paper.md 27 | path: paper/paper.pdf 28 | -------------------------------------------------------------------------------- /tests/canonical_configuration/test_canonical_configuration.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pathlib import Path 3 | 4 | parent = Path(__file__).parent 5 | folder = parent / "reference" 6 | 7 | 8 | def _check_numeric(character): 9 | try: 10 | float(character) 11 | return True 12 | except ValueError: 13 | return False 14 | 15 | 16 | def _read_log(file): 17 | rows = [] 18 | with open(file) as f: 19 | for line in f: 20 | rows.append([s for s in line.split() if _check_numeric(s)]) 21 | 22 | return np.nan_to_num(np.array(rows, dtype=float)) 23 | 24 | 25 | def test_log(file="canonical_configuration.dat"): 26 | data_ref = _read_log(folder / file) 27 | data_new = _read_log(parent / file) 28 | 29 | np.testing.assert_allclose(data_ref, data_new, err_msg=(parent / file).absolute()) 30 | 31 | 32 | if __name__ == "__main__": 33 | test_log() 34 | -------------------------------------------------------------------------------- /src/samples_from_md/Makefile: -------------------------------------------------------------------------------- 1 | include Makefile.inc 2 | CODE = samples_from_md 3 | PROG = ../../build/$(CODE)/$(CODE) 4 | OBJECT_PATH=../../build/$(CODE)/ 5 | 6 | OBJS = $(OBJECT_PATH)main.o $(OBJECT_PATH)options.o 7 | 8 | LPATH = -L../../lib $(blaslapackLPATH) $(incLPATHhdf) $(incLPATHmpi) 9 | IPATH = -I../../inc/libolle -I../../inc/libflap $(blaslapackIPATH) $(incIPATHhdf) $(incIPATHmpi) 10 | LIBS = ../../lib/libolle.a -lflap $(blaslapackLIBS) $(incLIBShdf) $(incLIBSmpi) 11 | 12 | F90 = $(FC) $(LPATH) $(IPATH) $(MODULE_FLAG) $(OBJECT_PATH) # $(warnings_gcc) 13 | F90FLAGS = $(OPT) $(MODS) $(LIBS) 14 | 15 | all: $(PROG) 16 | 17 | $(PROG): $(OBJS) 18 | $(F90) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) 19 | 20 | clean: 21 | rm -f $(PROG) $(OBJS) $(OBJECT_PATH)*.mod 22 | 23 | $(OBJECT_PATH)main.o: $(OBJECT_PATH)options.o 24 | $(F90) $(F90FLAGS) -c main.f90 $(LIBS) -o $@ 25 | $(OBJECT_PATH)options.o: 26 | $(F90) $(F90FLAGS) -c options.f90 $(LIBS) -o $@ 27 | 28 | -------------------------------------------------------------------------------- /src/pack_simulation/manual.md: -------------------------------------------------------------------------------- 1 | 2 | ## Long summary 3 | 4 | This utility takes the plain-text input files and packs them to hdf5. The options allow you to pack a subset and specify what information to include. The resulting output file can take the place of the regular input files. This is by no means a necessary tool, the main utility is reduced file size and increased io speed. 5 | 6 | ### Input files 7 | 8 | * [infile.ucposcar](../files.md#infile.ucposcar) 9 | * [infile.ssposcar](../files.md#infile.ucposcar) 10 | * [infile.positions](../files.md#infile.positions) 11 | * [infile.forces](../files.md#infile.forces) 12 | * [infile.stat](../files.md#infile.stat) 13 | * [infile.meta](../files.md#infile.meta) 14 | 15 | ### Output files 16 | 17 | #### `outfile.sim.hdf5` 18 | 19 | This is merely an archive that contains all the information in the input files but packed to a single file. For the casual use it has little benefit except using considerably less space. 20 | -------------------------------------------------------------------------------- /src/lineshape/meson.build: -------------------------------------------------------------------------------- 1 | executable('lineshape', 2 | 'dielscatter.f90', 3 | 'dielscatter_helper.f90', 4 | # 'dielscatter_matrixelement.f90', 5 | 'io.f90', 6 | 'lineshape_helper.f90', 7 | 'lo_realspace_selfenergy.f90', 8 | 'lo_thermal_transport.f90', 9 | 'main.f90', 10 | 'options.f90', 11 | 'phonondamping_aux.f90', 12 | 'phonondamping_dos.f90', 13 | 'phonondamping.f90', 14 | 'phonondamping_grid.f90', 15 | 'phonondamping_path.f90', 16 | 'scatteringrates.f90', 17 | link_with: [libolle, libflap], 18 | include_directories: ['../libolle', '../libflap'], 19 | dependencies: dep_all, 20 | install: true, 21 | install_dir: meson.project_build_root() / 'bin') 22 | 23 | install_symlink('lineshape', pointing_to: meson.project_build_root() / 'bin/lineshape', install_dir: meson.project_source_root() / 'bin') 24 | -------------------------------------------------------------------------------- /src/crystal_structure_info/Makefile: -------------------------------------------------------------------------------- 1 | include Makefile.inc 2 | CODE = crystal_structure_info 3 | PROG = ../../build/$(CODE)/$(CODE) 4 | OBJECT_PATH=../../build/$(CODE)/ 5 | 6 | OBJS = $(OBJECT_PATH)main.o $(OBJECT_PATH)options.o 7 | 8 | LPATH = -L../../lib $(blaslapackLPATH) $(incLPATHhdf) $(incLPATHmpi) 9 | IPATH = -I../../inc/libolle -I../../inc/libflap $(blaslapackIPATH) $(incIPATHhdf) $(incIPATHmpi) 10 | LIBS = ../../lib/libolle.a -lflap $(blaslapackLIBS) $(incLIBShdf) $(incLIBSmpi) 11 | 12 | #OPT = -O0 -fbacktrace -fcheck=all -finit-real=nan -finit-derived -fmax-errors=10 13 | F90 = $(FC) $(LPATH) $(IPATH) $(MODULE_FLAG) $(OBJECT_PATH) #$(warnings_gcc) 14 | F90FLAGS = $(OPT) $(MODS) $(LIBS) 15 | 16 | all: $(PROG) 17 | 18 | $(PROG): $(OBJS) 19 | $(F90) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) 20 | 21 | clean: 22 | rm -f $(PROG) $(OBJS) *.mod 23 | 24 | $(OBJECT_PATH)main.o: $(OBJECT_PATH)options.o 25 | $(F90) $(F90FLAGS) -c main.f90 $(LIBS) -o $@ 26 | $(OBJECT_PATH)options.o: 27 | $(F90) $(F90FLAGS) -c options.f90 $(LIBS) -o $@ 28 | 29 | -------------------------------------------------------------------------------- /src/libolle/type_forceconstant_firstorder_io.f90: -------------------------------------------------------------------------------- 1 | submodule(type_forceconstant_firstorder) type_forceconstant_firstorder_io 2 | use konstanter, only: lo_forceconstant_1st_HartreeBohr_to_eVA 3 | use gottochblandat, only: open_file 4 | implicit none 5 | contains 6 | 7 | !> write the forceconstant to file. 8 | module subroutine writetofile(fc, p, fn) 9 | !> second order force constant 10 | class(lo_forceconstant_firstorder), intent(in) :: fc 11 | !> crystal structure 12 | type(lo_crystalstructure), intent(in) :: p 13 | !> filename 14 | character(len=*), intent(in) :: fn 15 | 16 | integer :: ii, uu 17 | 18 | ! Dump it 19 | uu = open_file('out', trim(fn)) 20 | 21 | write (uu, "('# first order force constants for',I7,' atoms')") p%na 22 | 23 | do ii = 1, p%na 24 | associate (phi => fc%atom(ii)%m*lo_forceconstant_1st_HartreeBohr_to_eVA) 25 | write (uu, "(1X,3(1X,F20.15))") phi 26 | end associate 27 | end do 28 | 29 | close (uu) 30 | end subroutine 31 | 32 | end submodule 33 | -------------------------------------------------------------------------------- /src/manual/workflows/index.md: -------------------------------------------------------------------------------- 1 | title: Workflows 2 | author: Olle Hellman 3 | 4 | This series of workflows are writtin as a combination of instructions and tutorials. This software package is easy to use, but the underlying physics are not trivial. There are some deliberate barriers introduced as attempts to force a good understanding from the user. I am expecting limited success. 5 | 6 | The minimal examples should be done first, that each deal with fundamental parts: 7 | 8 | 1. [Example 1](minimal_example_1.html): will get you started and plot some stuff. 9 | 2. [Example 2](minimal_example_2.html): basic MD input preparation. 10 | 3. [Example 3](minimal_example_3.html): stochastic input preparation. 11 | 4. [Example 4](minimal_example_4.html): free energy. 12 | 5. [Example 5](minimal_example_5.html): thermal conductivity. 13 | 6. [Example 6](minimal_example_6.html): properties as a function of temperature. 14 | 15 | With that taken care, I plan to add proper examples of projects with production quality data. Dig up some old stuff I already published. 16 | -------------------------------------------------------------------------------- /src/pack_simulation/Makefile: -------------------------------------------------------------------------------- 1 | include Makefile.inc 2 | CODE = pack_simulation 3 | PROG = ../../build/$(CODE)/$(CODE) 4 | OBJECT_PATH=../../build/$(CODE)/ 5 | 6 | OBJS = $(OBJECT_PATH)main.o $(OBJECT_PATH)options.o 7 | 8 | LPATH = -L../../lib $(blaslapackLPATH) $(incLPATHhdf) $(incLPATHmpi) 9 | IPATH = -I../../inc/libolle -I../../inc/libflap $(blaslapackIPATH) $(incIPATHhdf) $(incIPATHmpi) 10 | LIBS = ../../lib/libolle.a -lflap $(blaslapackLIBS) $(incLIBShdf) $(incLIBSmpi) 11 | 12 | #OPT = -O0 -fbacktrace -fcheck=all -finit-real=nan -finit-derived -fmax-errors=10 13 | F90 = $(FC) $(LPATH) $(IPATH) $(MODULE_FLAG) $(OBJECT_PATH) 14 | F90FLAGS = $(OPT) $(MODS) $(LIBS) 15 | 16 | all: $(PROG) 17 | 18 | $(PROG): $(OBJS) 19 | $(F90) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) 20 | 21 | clean: 22 | rm -f $(PROG) $(OBJS) *.mod 23 | 24 | .f90.o: 25 | $(F90) $(F90FLAGS) -c $< $(LIBS) 26 | 27 | $(OBJECT_PATH)main.o: $(OBJECT_PATH)options.o 28 | $(F90) $(F90FLAGS) -c main.f90 $(LIBS) -o $@ 29 | $(OBJECT_PATH)options.o: 30 | $(F90) $(F90FLAGS) -c options.f90 $(LIBS) -o $@ 31 | -------------------------------------------------------------------------------- /tests/thermal_conductivity_2023/reference/outfile.thermal_conductivity: -------------------------------------------------------------------------------- 1 | 0.1000000000E+03 0.9484478410E+02 0.9484241022E+02 0.9485158261E+02 -0.6914668975E-02 0.4605053895E-02 0.6943480313E-02 -0.3419399398E-02 -0.4609991003E-02 -0.5346988618E-02 2 | 0.1500000000E+03 0.7765603795E+02 0.7765355763E+02 0.7765502331E+02 -0.4821178917E-02 0.7814554039E-03 0.4901081212E-02 -0.3165046775E-02 -0.6334968858E-03 -0.1153689678E-02 3 | 0.2000000000E+03 0.6534894912E+02 0.6534778505E+02 0.6534831799E+02 -0.3344794089E-02 0.3490276769E-03 0.3488810159E-02 -0.1518867629E-02 0.8153799649E-04 -0.4263176402E-03 4 | 0.2500000000E+03 0.5612079252E+02 0.5612029951E+02 0.5612055692E+02 -0.2469080777E-02 0.1152899888E-03 0.2680884747E-02 -0.6505521420E-03 0.1152899888E-03 -0.1224973560E-03 5 | 0.3000000000E+03 0.4900053998E+02 0.4900037109E+02 0.4900051271E+02 -0.1924940461E-02 0.1486555118E-03 0.2204538394E-02 -0.2163160728E-03 0.1486555118E-03 0.4581584256E-04 6 | -------------------------------------------------------------------------------- /src/dump_dynamical_matrices/Makefile: -------------------------------------------------------------------------------- 1 | include Makefile.inc 2 | CODE = dump_dynamical_matrices 3 | PROG = ../../build/$(CODE)/$(CODE) 4 | OBJECT_PATH=../../build/$(CODE)/ 5 | 6 | OBJS = $(OBJECT_PATH)main.o $(OBJECT_PATH)options.o 7 | 8 | LPATH = -L../../lib $(blaslapackLPATH) $(incLPATHhdf) $(incLPATHmpi) $(incLPATHfft) 9 | IPATH = -I../../inc/libolle -I../../inc/libflap $(blaslapackIPATH) $(incIPATHhdf) $(incIPATHmpi) $(incIPATHfft) 10 | LIBS = ../../lib/libolle.a -lflap $(blaslapackLIBS) $(incLIBShdf) $(incLIBSmpi) $(incLIBSfft) 11 | 12 | # ok, I think I get this. 13 | #OPT = -O0 -fbacktrace -fcheck=all -finit-real=nan -finit-derived -fmax-errors=10 14 | F90 = $(FC) $(LPATH) $(IPATH) $(MODULE_FLAG) $(OBJECT_PATH) #$(warnings_gcc) 15 | F90FLAGS = $(OPT) $(MODS) $(LIBS) 16 | 17 | all: $(PROG) 18 | 19 | $(PROG): $(OBJS) 20 | $(F90) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) 21 | 22 | clean: 23 | rm -f $(PROG) $(OBJS) *.mod $(OBJECT_PATH)*.mod 24 | 25 | 26 | $(OBJECT_PATH)main.o: $(OBJECT_PATH)options.o ../../lib/libolle.a 27 | $(F90) $(F90FLAGS) -c main.f90 -o $@ 28 | $(OBJECT_PATH)options.o: 29 | $(F90) $(F90FLAGS) -c options.f90 -o $@ 30 | -------------------------------------------------------------------------------- /src/extract_forceconstants/Makefile: -------------------------------------------------------------------------------- 1 | include Makefile.inc 2 | CODE = extract_forceconstants 3 | PROG = ../../build/$(CODE)/$(CODE) 4 | OBJECT_PATH=../../build/$(CODE)/ 5 | 6 | OBJS = \ 7 | $(OBJECT_PATH)main.o\ 8 | $(OBJECT_PATH)options.o 9 | 10 | LPATH = -L../../lib $(blaslapackLPATH) $(incLPATHhdf) $(incLPATHmpi) 11 | IPATH = -I../../inc/libolle -I../../inc/libflap $(blaslapackIPATH) $(incLPATHhdf) $(incIPATHmpi) 12 | LIBS = ../../lib/libolle.a -lflap $(blaslapackLIBS) ${incIPATHhdf} $(incLIBShdf) $(incLIBSmpi) 13 | 14 | #OPT = -O0 -fcheck=all -fbacktrace -finit-real=nan -finit-derived -fmax-errors=10 15 | F90 = $(FC) $(LPATH) $(IPATH) $(MODULE_FLAG) $(OBJECT_PATH) 16 | F90FLAGS = $(OPT) $(MODS) $(LIBS) 17 | 18 | all: $(PROG) 19 | 20 | $(PROG): $(OBJS) 21 | $(F90) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) 22 | 23 | clean: 24 | rm -f $(PROG) $(OBJS) $(OBJECT_PATH)*.mod 25 | 26 | .f90.o: 27 | $(F90) $(F90FLAGS) -c $< $(LIBS) 28 | 29 | $(OBJECT_PATH)main.o: main.f90 $(OBJECT_PATH)options.o 30 | $(F90) $(F90FLAGS) -c main.f90 $(LIBS) -o $@ 31 | $(OBJECT_PATH)options.o: options.f90 32 | $(F90) $(F90FLAGS) -c options.f90 $(LIBS) -o $@ 33 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016- Olle Hellman and friends 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /src/canonical_configuration/Makefile: -------------------------------------------------------------------------------- 1 | include Makefile.inc 2 | CODE = canonical_configuration 3 | PROG = ../../build/$(CODE)/$(CODE) 4 | OBJECT_PATH=../../build/$(CODE)/ 5 | 6 | OBJS = $(OBJECT_PATH)main.o $(OBJECT_PATH)options.o $(OBJECT_PATH)semirandom.o 7 | 8 | LPATH = -L../../lib $(blaslapackLPATH) $(incLPATHhdf) $(incLPATHmpi) 9 | IPATH = -I../../inc/libolle -I../../inc/libflap $(blaslapackIPATH) $(incIPATHhdf) $(incIPATHmpi) 10 | LIBS = ../../lib/libolle.a -lflap $(blaslapackLIBS) $(incLIBShdf) $(incLIBSmpi) 11 | 12 | #OPT = -O0 -fbacktrace -fcheck=all -finit-real=nan -finit-derived -fmax-errors=10 13 | 14 | F90 = $(FC) $(LPATH) $(IPATH) $(MODULE_FLAG) $(OBJECT_PATH) #$(warnings_gcc) 15 | F90FLAGS = $(OPT) $(MODS) $(LIBS) 16 | 17 | all: $(PROG) 18 | 19 | $(PROG): $(OBJS) 20 | $(F90) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) 21 | 22 | clean: 23 | rm -f $(PROG) $(OBJS) $(OBJECT_PATH)*.mod 24 | 25 | $(OBJECT_PATH)main.o: $(OBJECT_PATH)options.o $(OBJECT_PATH)semirandom.o 26 | $(F90) $(F90FLAGS) -c main.f90 $(LIBS) -o $@ 27 | $(OBJECT_PATH)semirandom.o: 28 | $(F90) $(F90FLAGS) -c semirandom.f90 $(LIBS) -o $@ 29 | $(OBJECT_PATH)options.o: 30 | $(F90) $(F90FLAGS) -c options.f90 $(LIBS) -o $@ 31 | -------------------------------------------------------------------------------- /src/libflap/LICENSE.mit.md: -------------------------------------------------------------------------------- 1 | The MIT License 2 | =============== 3 | 4 | Copyright (c) 2015 Stefano Zaghi 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /tests/thermal_conductivity_2023/test_thermal_conductivity_2023.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import xarray as xr 3 | from pathlib import Path 4 | 5 | parent = Path(__file__).parent 6 | folder = parent / "reference" 7 | 8 | files_hdf5 = [ 9 | "outfile.cumulative_kappa.hdf5", 10 | ] 11 | 12 | 13 | def test_thermal_conductivity(file="outfile.thermal_conductivity", atol=20, rtol=5): 14 | file_ref = folder / file 15 | file_new = parent / file 16 | 17 | data_ref = np.loadtxt(file_ref) 18 | data_new = np.loadtxt(file_new) 19 | 20 | np.testing.assert_allclose( 21 | data_ref, data_new, atol=atol, rtol=rtol, err_msg=file_new.absolute() 22 | ) 23 | 24 | 25 | def test_hdf5(files=files_hdf5, atol=1, rtol=0.01): 26 | for file in files: 27 | file_ref = folder / file 28 | file_new = parent / file 29 | 30 | ds_ref = xr.load_dataset(file_ref) 31 | ds_new = xr.load_dataset(file_new) 32 | 33 | for var in ds_ref.data_vars: 34 | x = ds_ref[var] 35 | y = ds_new[var] 36 | np.testing.assert_allclose(x, y, atol=atol, rtol=rtol, err_msg=var) 37 | 38 | 39 | if __name__ == "__main__": 40 | test_thermal_conductivity() 41 | test_hdf5() 42 | -------------------------------------------------------------------------------- /src/libflap/flap.f90: -------------------------------------------------------------------------------- 1 | !< FLAP, Fortran command Line Arguments Parser for poor people 2 | module flap 3 | !----------------------------------------------------------------------------------------------------------------------------------- 4 | !< FLAP, Fortran command Line Arguments Parser for poor people 5 | !<{!README-FLAP.md!} 6 | !----------------------------------------------------------------------------------------------------------------------------------- 7 | use flap_command_line_argument_t, only : command_line_argument 8 | use flap_command_line_arguments_group_t, only : command_line_arguments_group 9 | use flap_command_line_interface_t, only : command_line_interface 10 | !----------------------------------------------------------------------------------------------------------------------------------- 11 | 12 | !----------------------------------------------------------------------------------------------------------------------------------- 13 | implicit none 14 | private 15 | public :: command_line_argument 16 | public :: command_line_arguments_group 17 | public :: command_line_interface 18 | !----------------------------------------------------------------------------------------------------------------------------------- 19 | endmodule flap 20 | -------------------------------------------------------------------------------- /src/phasespace_surface/Makefile: -------------------------------------------------------------------------------- 1 | include Makefile.inc 2 | CODE = phasespace_surface 3 | PROG = ../../build/$(CODE)/$(CODE) 4 | OBJECT_PATH=../../build/$(CODE)/ 5 | 6 | OBJS = $(OBJECT_PATH)main.o $(OBJECT_PATH)options.o $(OBJECT_PATH)type_phasespacesurface.o 7 | 8 | LPATH = -L../../lib $(blaslapackLPATH) $(incLPATHhdf) $(incLPATHmpi) 9 | IPATH = -I../../inc/libolle -I../../inc/libflap $(blaslapackIPATH) $(incIPATHhdf) $(incIPATHmpi) 10 | LIBS = ../../lib/libolle.a -lflap $(blaslapackLIBS) $(incLIBShdf) $(incLIBSmpi) 11 | 12 | #OPT = -O0 -fbacktrace -fcheck=all -finit-real=nan -finit-derived -fmax-errors=10 13 | F90 = $(FC) $(LPATH) $(IPATH) $(MODULE_FLAG) $(OBJECT_PATH) 14 | F90FLAGS = $(OPT) $(MODS) $(LIBS) 15 | 16 | all: $(PROG) 17 | 18 | $(PROG): $(OBJS) 19 | $(F90) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) 20 | 21 | clean: 22 | rm -f $(PROG) $(OBJS) *.mod 23 | 24 | .f90.o: 25 | $(F90) $(F90FLAGS) -c $< $(LIBS) 26 | 27 | $(OBJECT_PATH)main.o: $(OBJECT_PATH)options.o $(OBJECT_PATH)type_phasespacesurface.o 28 | $(F90) $(F90FLAGS) -c main.f90 $(LIBS) -o $@ 29 | $(OBJECT_PATH)options.o: 30 | $(F90) $(F90FLAGS) -c options.f90 $(LIBS) -o $@ 31 | $(OBJECT_PATH)type_phasespacesurface.o: 32 | $(F90) $(F90FLAGS) -c type_phasespacesurface.f90 $(LIBS) -o $@ 33 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/error.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Error 3 | about: Report a TDEP error message and ask for help 4 | title: "[ERROR] Your error message" 5 | labels: error 6 | assignees: '' 7 | 8 | --- 9 | 10 | Before reporting an error, please check if your problem was already covered in on of the following resources: 11 | 12 | - [ ] [Troubleshooting section](https://github.com/tdep-developers/tdep?tab=readme-ov-file#troubleshooting) 13 | - [ ] [Issue tracker](https://github.com/tdep-developers/tdep/issues) including [closed issues](https://github.com/tdep-developers/tdep/issues?q=is%3Aissue+is%3Aclosed) 14 | 15 | If this did not help, please report your error detailed as possible. 16 | 17 | Therefore, please provide the following: 18 | 19 | - [ ] Report the `git commit` or release version of TDEP that you are working with. 20 | - [ ] Describe the error message you encountered. 21 | - [ ] Provide the **full command** you were running (e.g. `extract_forceconstants -rc2 5`) 22 | - [ ] If you are using a script to run or submit the command, please provide this script as well 23 | - [ ] Add a **full** log file for the binary you were running (e.g. via ``extract_forceconstants -rc2 5 2>&1 | tee extract_forceconstants.log`) 24 | - [ ] Add **all input files** necessary to run the command 25 | -------------------------------------------------------------------------------- /src/refine_structure/manual.md: -------------------------------------------------------------------------------- 1 | 2 | ### Longer summary 3 | 4 | This is a utility to ensure that the symmetries of the crystal structure is satisfied to as high precision as possible. A vast majority of issues users experience, can be solved with this tool. 5 | 6 | In essence, it takes an input crystal structure that might be specified like this 7 | 8 | ``` 9 | hcp Fe 10 | 2.4 11 | 0.50000 -0.866025 0.00000 12 | 0.50000 0.866025 0.00000 13 | 0.00000 0.000000 1.63299 14 | Fe 15 | 2 16 | Direct 17 | 0.333333 0.66666 0.25000 18 | 0.666666 0.33333 0.75000 19 | ``` 20 | 21 | And returns 22 | 23 | ``` 24 | hcp Fe 25 | 2.399999720250 26 | 0.50000000000000 -0.86602540378444 0.00000000000000 27 | 0.50000000000000 0.86602540378444 0.00000000000000 28 | 0.00000000000000 0.00000000000000 1.63299057103649 29 | Fe 30 | 2 31 | Direct coordinates 32 | 0.33333333333333 0.66666666666667 0.25000000000000 site 1 species 1: Fe 33 | 0.66666666666667 0.33333333333333 0.75000000000000 site 2 species 1: Fe 34 | ``` 35 | 36 | !!! note 37 | Explain that we can use a prototype structure to determine the spacegroup, as in pick spacegroup from a unit cell I know is ok, and impose that on the current cell. 38 | 39 | 40 | -------------------------------------------------------------------------------- /tests/atomic_distribution/test_atomic_distribution.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import xarray as xr 3 | from pathlib import Path 4 | 5 | parent = Path(__file__).parent 6 | folder = parent / "reference" 7 | 8 | files_hdf5 = [ 9 | "outfile.mean_square_displacement.hdf5", 10 | "outfile.pair_distribution.hdf5", 11 | "outfile.powder_diffraction.hdf5", 12 | ] 13 | 14 | 15 | def test_mean_square_displacement(file="outfile.mean_square_displacement"): 16 | file_ref = folder / file 17 | file_new = parent / file 18 | 19 | data_ref = np.loadtxt(file_ref) 20 | data_new = np.loadtxt(file_new) 21 | 22 | np.testing.assert_allclose(data_ref, data_new, err_msg=file_new.absolute()) 23 | 24 | 25 | def test_hdf5(files=files_hdf5, decimals=7): 26 | for file in files: 27 | file_ref = folder / file 28 | file_new = parent / file 29 | 30 | ds_ref = xr.load_dataset(file_ref) 31 | ds_new = xr.load_dataset(file_new) 32 | 33 | for var in ds_ref.data_vars: 34 | x = ds_ref[var].round(decimals=decimals) 35 | y = ds_new[var].round(decimals=decimals) 36 | np.testing.assert_allclose(x, y, err_msg=var) 37 | 38 | 39 | if __name__ == "__main__": 40 | test_mean_square_displacement() 41 | test_hdf5() 42 | -------------------------------------------------------------------------------- /tests/thermal_conductivity/test_thermal_conductivity.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import xarray as xr 3 | from pathlib import Path 4 | 5 | parent = Path(__file__).parent 6 | folder = parent / "reference" 7 | 8 | file = "outfile.thermal_conductivity" 9 | file_hdf5 = "outfile.thermal_conductivity_grid.hdf5" 10 | 11 | 12 | def test_thermal_conductivity(file=file, atol=1, rtol=0.1): 13 | file_ref = folder / file 14 | file_new = parent / file 15 | 16 | data_ref = np.loadtxt(file_ref) 17 | data_new = np.loadtxt(file_new) 18 | 19 | np.testing.assert_allclose( 20 | data_ref, data_new, atol=atol, rtol=rtol, err_msg=file_new.absolute() 21 | ) 22 | 23 | 24 | def test_conductivity_comparison( 25 | file=parent / file, 26 | file_grid=parent / file_hdf5, 27 | ): 28 | """Check if the thermal conducivities conincide""" 29 | data1 = np.loadtxt(file) 30 | 31 | # without off-diagonal contribution 32 | kappa1 = data1[0][:3] + data1[1][:3] 33 | 34 | ds = xr.load_dataset(file_grid) 35 | 36 | kappa2 = np.diag(ds.thermal_conductivity.sum(axis=(0, 1)) / ds.number_of_qpoints) 37 | 38 | np.testing.assert_allclose(kappa1, kappa2) 39 | 40 | 41 | if __name__ == "__main__": 42 | test_thermal_conductivity() 43 | test_conductivity_comparison() 44 | -------------------------------------------------------------------------------- /src/anharmonic_free_energy/Makefile: -------------------------------------------------------------------------------- 1 | include Makefile.inc 2 | CODE=anharmonic_free_energy 3 | PROG=../../build/$(CODE)/$(CODE) 4 | OBJECT_PATH=../../build/$(CODE)/ 5 | 6 | OBJS = $(OBJECT_PATH)main.o $(OBJECT_PATH)options.o $(OBJECT_PATH)energy.o $(OBJECT_PATH)epot.o 7 | 8 | LPATH = -L../../lib $(blaslapackLPATH) $(incLPATHhdf) $(incLPATHmpi) 9 | IPATH = -I../../inc/libolle -I../../inc/libflap $(blaslapackIPATH) $(incIPATHhdf) $(incIPATHmpi) 10 | LIBS = ../../lib/libolle.a -lflap $(blaslapackLIBS) $(incLIBShdf) $(incLIBSmpi) 11 | 12 | #OPT = -O0 -fbacktrace -fcheck=all -Wall 13 | F90 = $(FC) $(LPATH) $(IPATH) $(MODULE_FLAG) $(OBJECT_PATH) 14 | F90FLAGS = $(OPT) $(MODS) $(LIBS) 15 | 16 | all: $(PROG) 17 | 18 | $(PROG): $(OBJS) 19 | $(F90) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) 20 | 21 | clean: 22 | rm -f $(PROG) $(OBJS) *.mod 23 | 24 | .f90.o: 25 | $(F90) $(F90FLAGS) -c $< $(LIBS) 26 | 27 | $(OBJECT_PATH)main.o: main.f90 $(OBJECT_PATH)options.o $(OBJECT_PATH)energy.o $(OBJECT_PATH)epot.o 28 | $(F90) $(F90FLAGS) -c main.f90 $(LIBS) -o $@ 29 | $(OBJECT_PATH)energy.o: $(OBJECT_PATH)options.o 30 | $(F90) $(F90FLAGS) -c energy.f90 $(LIBS) -o $@ 31 | $(OBJECT_PATH)options.o: 32 | $(F90) $(F90FLAGS) -c options.f90 $(LIBS) -o $@ 33 | $(OBJECT_PATH)epot.o: epot.f90 34 | $(F90) $(F90FLAGS) -c epot.f90 $(LIBS) -o $@ 35 | 36 | -------------------------------------------------------------------------------- /tests/canonical_configuration/reference/canonical_configuration.dat: -------------------------------------------------------------------------------- 1 | 1 + 0.00000 0.00000 NaN 0.00000 0.00000 0.00000000 2 | 2 - 0.00000 0.00000 NaN 0.00000 0.00000 0.00000000 3 | 3 + 0.00000 0.00000 NaN 0.00000 0.00000 0.00000000 4 | 4 - 0.00000 0.00000 NaN 0.00000 0.00000 0.00000000 5 | 5 + 0.00000 0.00000 NaN 0.00000 0.00000 0.00000000 6 | 6 - 0.00000 0.00000 NaN 0.00000 0.00000 0.00000000 7 | 7 + 50.00000 50.00000 1.00000 50.00000 7.14286 0.00397797 8 | 8 - 50.00000 50.00000 1.00000 50.00000 12.50000 0.00696145 9 | 9 + 50.00000 50.00000 1.00000 50.00000 16.66667 0.00928193 10 | 10 - 50.00000 50.00000 1.00000 50.00000 20.00000 0.01113832 11 | 11 + 50.00000 20.79236 1.13229 35.39618 21.39965 0.01175817 12 | 12 - 50.00000 20.79236 1.24180 35.39618 22.56603 0.01227471 13 | -------------------------------------------------------------------------------- /meson.build: -------------------------------------------------------------------------------- 1 | project('tdep', 'fortran', 'c', 'cpp') 2 | add_project_arguments('-cpp', language: 'fortran') 3 | add_project_arguments('-ffree-line-length-none', language: 'fortran') 4 | # add_project_arguments('-std=f2008', language: 'fortran') 5 | add_project_arguments('-fallow-argument-mismatch', language: 'fortran') 6 | 7 | # global dependencies: 8 | dep_mpi = dependency('mpi', language: 'fortran') 9 | dep_blas = dependency('blas') 10 | dep_lapack = dependency('lapack') 11 | dep_fftw = dependency('fftw3') 12 | dep_hdf5 = dependency('hdf5', language: 'fortran', version: '>1.10.7') 13 | dep_netcdf = dependency('netcdf', language: 'fortran') 14 | dep_all = [dep_mpi, dep_blas, dep_lapack, dep_fftw, dep_hdf5, dep_netcdf] 15 | 16 | subdir('src/libolle') 17 | subdir('src/libflap') 18 | 19 | subdir('src/anharmonic_free_energy') 20 | subdir('src/atomic_distribution') 21 | subdir('src/canonical_configuration') 22 | subdir('src/crystal_structure_info') 23 | subdir('src/dump_dynamical_matrices') 24 | subdir('src/extract_forceconstants') 25 | subdir('src/generate_structure') 26 | subdir('src/lineshape') 27 | subdir('src/pack_simulation') 28 | subdir('src/phasespace_surface') 29 | subdir('src/phonon_dispersion_relations') 30 | subdir('src/refine_structure') 31 | subdir('src/samples_from_md') 32 | subdir('src/thermal_conductivity') 33 | subdir('src/thermal_conductivity_2023') 34 | -------------------------------------------------------------------------------- /src/libolle/type_forceconstant_firstorder.f90: -------------------------------------------------------------------------------- 1 | #include "precompilerdefinitions" 2 | module type_forceconstant_firstorder 3 | use konstanter, only: flyt, lo_huge, lo_hugeint 4 | use type_crystalstructure, only: lo_crystalstructure 5 | implicit none 6 | 7 | private 8 | public :: lo_forceconstant_firstorder 9 | 10 | type lo_fc1_atom 11 | !> index in the unit cell to the atom 12 | integer :: i1 = -lo_hugeint 13 | !> absolute vectors positioning the atoms 14 | real(flyt), dimension(3) :: v1 = lo_huge 15 | !> lattice vectors positioning the unit cell 16 | real(flyt), dimension(3) :: lv1 = lo_huge 17 | !> the force constant matrix 18 | real(flyt), dimension(3) :: m = lo_huge 19 | end type 20 | 21 | type lo_forceconstant_firstorder 22 | !> number of atoms 23 | integer :: na = -lo_hugeint 24 | !> info about each atom 25 | type(lo_fc1_atom), allocatable, dimension(:) :: atom 26 | 27 | contains 28 | !> write to file 29 | procedure :: writetofile 30 | end type 31 | 32 | ! Interfaces to type_forceconstant_firstorder_io 33 | interface 34 | module subroutine writetofile(fc, p, fn) 35 | class(lo_forceconstant_firstorder), intent(in) :: fc 36 | type(lo_crystalstructure), intent(in) :: p 37 | character(len=*), intent(in) :: fn 38 | end subroutine 39 | end interface 40 | 41 | contains 42 | 43 | end module 44 | -------------------------------------------------------------------------------- /tests/extract_forceconstants/test_extract_forceconstants.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pathlib import Path 3 | 4 | parent = Path(__file__).parent 5 | folder = parent / "reference" 6 | 7 | 8 | def _read_fc(file, offset1, offset2): 9 | rows = [] 10 | with open(file) as f: 11 | # read header 12 | next(f) 13 | next(f) 14 | nneighbors = int(next(f).split()[0]) 15 | 16 | lines = f.readlines() 17 | 18 | for ii in range(nneighbors): 19 | row = lines[ii * offset1 + offset2 : (ii + 1) * offset1] 20 | rows.append(np.fromstring("".join(row), sep=" ")) 21 | 22 | return np.array(rows) 23 | 24 | 25 | def _read_fc2(file): 26 | return _read_fc(file, offset1=5, offset2=2) 27 | 28 | 29 | def _read_fc3(file): 30 | return _read_fc(file, offset1=15, offset2=3) 31 | 32 | 33 | def test_fc2(file="outfile.forceconstant"): 34 | data_ref = _read_fc2(folder / file) 35 | data_new = _read_fc2(parent / file) 36 | 37 | np.testing.assert_allclose(data_ref, data_new, err_msg=(parent / file).absolute()) 38 | 39 | 40 | def test_fc3(file="outfile.forceconstant_thirdorder"): 41 | data_ref = _read_fc3(folder / file) 42 | data_new = _read_fc3(parent / file) 43 | 44 | np.testing.assert_allclose(data_ref, data_new, err_msg=(parent / file).absolute()) 45 | 46 | 47 | if __name__ == "__main__": 48 | test_fc2() 49 | test_fc3() 50 | -------------------------------------------------------------------------------- /tests/thermal_conductivity/reference/outfile.thermal_conductivity: -------------------------------------------------------------------------------- 1 | # Unit: W/m/K 2 | # Temperature: 0.300000000000E+03 3 | # Single mode approximation 4 | # kxx kyy kzz kxy kxz kyz 5 | 0.487382103035E+02 0.487382103035E+02 0.487382103035E+02 0.000000000000E+00 0.000000000000E+00 0.000000000000E+00 6 | # Collective contribution 7 | # kxx kyy kzz kxy kxz kyz 8 | 0.255832668695E+01 0.255832668695E+01 0.255832668695E+01 0.000000000000E+00 0.000000000000E+00 0.000000000000E+00 9 | # Off diagonal (coherence) contribution 10 | # kxx kyy kzz kxy kxz kyz 11 | 0.215161320755E-01 0.215161320755E-01 0.215161320755E-01 0.000000000000E+00 0.000000000000E+00 0.000000000000E+00 12 | # Total thermal conductivity 13 | # kxx kyy kzz kxy kxz kyz 14 | 0.513180531225E+02 0.513180531225E+02 0.513180531225E+02 0.000000000000E+00 0.000000000000E+00 0.000000000000E+00 15 | -------------------------------------------------------------------------------- /src/generate_structure/Makefile: -------------------------------------------------------------------------------- 1 | include Makefile.inc 2 | CODE = generate_structure 3 | PROG = ../../build/$(CODE)/$(CODE) 4 | OBJECT_PATH=../../build/$(CODE)/ 5 | 6 | # OBJS = $(OBJECT_PATH)main.o $(OBJECT_PATH)options.o $(OBJECT_PATH)magneticdisorder.o $(OBJECT_PATH)autocell.o 7 | OBJS = $(OBJECT_PATH)main.o $(OBJECT_PATH)options.o $(OBJECT_PATH)autocell.o 8 | 9 | 10 | #OPT = -O0 -fbacktrace -fcheck=all -finit-real=nan -finit-derived -fmax-errors=10 11 | LPATH = -L../../lib $(blaslapackLPATH) $(incLPATHhdf) $(incLPATHmpi) 12 | IPATH = -I../../inc/libolle -I../../inc/libflap $(blaslapackIPATH) $(incIPATHhdf) $(incIPATHmpi) 13 | LIBS = ../../lib/libolle.a -lflap $(blaslapackLIBS) $(incLIBShdf) $(incLIBSmpi) 14 | 15 | F90 = $(FC) $(LPATH) $(IPATH) $(MODULE_FLAG) $(OBJECT_PATH) # $(warnings_gcc) 16 | F90FLAGS = $(OPT) $(MODS) $(LIBS) 17 | 18 | all: $(PROG) 19 | 20 | $(PROG): $(OBJS) 21 | $(F90) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) 22 | 23 | clean: 24 | rm -f $(PROG) $(OBJS) $(OBJECT_PATH)*.mod 25 | 26 | # $(OBJECT_PATH)main.o: $(OBJECT_PATH)options.o $(OBJECT_PATH)magneticdisorder.o $(OBJECT_PATH)autocell.o 27 | $(OBJECT_PATH)main.o: $(OBJECT_PATH)options.o $(OBJECT_PATH)autocell.o 28 | $(F90) $(F90FLAGS) -c main.f90 $(LIBS) -o $@ 29 | $(OBJECT_PATH)autocell.o: 30 | $(F90) $(F90FLAGS) -c autocell.f90 $(LIBS) -o $@ 31 | $(OBJECT_PATH)options.o: 32 | $(F90) $(F90FLAGS) -c options.f90 $(LIBS) -o $@ 33 | # $(OBJECT_PATH)magneticdisorder.o: 34 | # $(F90) $(F90FLAGS) -c magneticdisorder.f90 $(LIBS) -o $@ 35 | 36 | -------------------------------------------------------------------------------- /src/phasespace_surface/type_phasespacesurface_energycalculations.f90: -------------------------------------------------------------------------------- 1 | 2 | subroutine energy_values_on_vertices(qp1, qp, uc, fc, energy_plus, energy_minus, mem) 3 | !> the q-point in question 4 | type(lo_qpoint), intent(in) :: qp1 5 | !> qpoint mesh 6 | class(lo_qpoint_mesh), intent(in) :: qp 7 | !> unitcell 8 | type(lo_crystalstructure), intent(in) :: uc 9 | !> forceconstant 10 | type(lo_forceconstant_secondorder), intent(inout) :: fc 11 | !> energy values 12 | real(flyt), dimension(:, :, :, :), intent(out) :: energy_plus, energy_minus 13 | !> memory helper 14 | type(lo_mem_helper), intent(inout) :: mem 15 | ! 16 | type(lo_qpoint) :: qp2, qp3 17 | type(lo_phonon_dispersions_qpoint) :: drp1, drp2, drp3 18 | integer :: i, nb, b1, b2, b3 19 | ! 20 | nb = fc%na*3 21 | energy_plus = 0.0_flyt 22 | energy_minus = 0.0_flyt 23 | ! get the starting point 24 | call drp1%generate(fc, uc, mem, qp1) 25 | do i = 1, qp%n_full_point 26 | qp2%r = qp%ap(i)%r 27 | qp2%n_invariant_operation = 0 28 | qp3%r = qp2%r + qp1%r 29 | qp3%n_invariant_operation = 0 30 | call drp2%generate(fc, uc, mem, qp2) 31 | call drp3%generate(fc, uc, mem, qp3) 32 | do b1 = 1, nb 33 | do b2 = 1, nb 34 | do b3 = 1, nb 35 | energy_plus(i, b1, b2, b3) = drp1%omega(b1) + drp2%omega(b2) - drp3%omega(b3) 36 | energy_minus(i, b1, b2, b3) = drp1%omega(b1) - drp2%omega(b2) - drp3%omega(b3) 37 | end do 38 | end do 39 | end do 40 | end do 41 | end subroutine 42 | 43 | -------------------------------------------------------------------------------- /src/thermal_conductivity/Makefile: -------------------------------------------------------------------------------- 1 | include Makefile.inc 2 | CODE = thermal_conductivity 3 | PROG = ../../build/$(CODE)/$(CODE) 4 | OBJECT_PATH=../../build/$(CODE)/ 5 | 6 | OBJS = \ 7 | $(OBJECT_PATH)main.o\ 8 | $(OBJECT_PATH)options.o\ 9 | $(OBJECT_PATH)scattering.o\ 10 | $(OBJECT_PATH)kappa.o\ 11 | $(OBJECT_PATH)cumulative_kappa.o 12 | 13 | LPATH = -L../../lib $(blaslapackLPATH) $(incLPATHmpi) $(incLPATHhdf) 14 | IPATH = -I../../inc/libolle -I../../inc/libflap $(blaslapackIPATH) $(incIPATHmpi) $(incIPATHhdf) 15 | LIBS = ../../lib/libolle.a -lflap $(blaslapackLIBS) $(incLIBSmpi) $(incLIBShdf) 16 | 17 | #OPT = -O0 -fbacktrace -fcheck=all -finit-real=nan -finit-derived 18 | F90 = $(FC) $(LPATH) $(IPATH) $(MODULE_FLAG) $(OBJECT_PATH) #$(warnings_gcc) 19 | F90FLAGS = $(OPT) $(MODS) $(LIBS) 20 | 21 | all: $(PROG) 22 | 23 | $(PROG): $(OBJS) 24 | $(F90) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) 25 | 26 | clean: 27 | rm -f $(PROG) $(OBJS) $(OBJECT_PATH)*.mod 28 | 29 | $(OBJECT_PATH)main.o: \ 30 | main.f90\ 31 | $(OBJECT_PATH)options.o\ 32 | $(OBJECT_PATH)scattering.o\ 33 | $(OBJECT_PATH)kappa.o\ 34 | $(OBJECT_PATH)cumulative_kappa.o 35 | $(F90) $(OPT) $(F90FLAGS) -c $< $(LIBS) -o $@ 36 | $(OBJECT_PATH)scattering.o: scattering.f90 37 | $(F90) $(OPT) $(F90FLAGS) -c $< $(LIBS) -o $@ 38 | $(OBJECT_PATH)kappa.o:\ 39 | kappa.f90\ 40 | $(OBJECT_PATH)scattering.o 41 | $(F90) $(OPT) $(F90FLAGS) -c $< $(LIBS) -o $@ 42 | $(OBJECT_PATH)cumulative_kappa.o: cumulative_kappa.f90\ 43 | $(OBJECT_PATH)kappa.o 44 | $(F90) $(OPT) $(F90FLAGS) -c $< $(LIBS) -o $@ 45 | $(OBJECT_PATH)options.o: options.f90 46 | $(F90) $(OPT) $(F90FLAGS) -c $< $(LIBS) -o $@ 47 | -------------------------------------------------------------------------------- /src/libflap/LICENSE.bsd-3.md: -------------------------------------------------------------------------------- 1 | Modified BSD License 2 | ==================== 3 | 4 | Copyright © 2015, Stefano Zaghi 5 | 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. Neither the name of the FLAP nor the 17 | names of its contributors may be used to endorse or promote products 18 | derived from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND 21 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL Stefano Zaghi BE LIABLE FOR ANY 24 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /src/dump_dynamical_matrices/options.f90: -------------------------------------------------------------------------------- 1 | #include "precompilerdefinitions" 2 | module options 3 | ! 4 | use konstanter 5 | use flap 6 | 7 | type lo_opts 8 | !> q-grid density 9 | integer, dimension(3) :: qgrid 10 | !> what kind of qgrid 11 | integer :: meshtype 12 | !> read it from file instead 13 | logical :: readqpointsfromfile 14 | contains 15 | procedure :: parse 16 | end type 17 | 18 | contains 19 | 20 | subroutine parse(opts) 21 | !> the options 22 | class(lo_opts), intent(out) :: opts 23 | 24 | ! the parser 25 | type(command_line_interface) :: cli 26 | 27 | ! basic stuff, for the help thingy 28 | call cli%init(progname='dump_dynamical_matrices', & 29 | authors=lo_author, & 30 | version=lo_version, & 31 | license=lo_licence, & 32 | help='Usage: ', & 33 | description='Dump the dynamical matrices to file, either on a grid or at the points specified by a file.', & 34 | epilog=new_line('a')//"...") 35 | 36 | cli_qpoint_grid 37 | cli_meshtype 38 | ! 39 | call cli%add(switch='--readqpoints', & 40 | help='Instead of generating a q-mesh, read it in fractional coordinates from a file called "infile.dynmatqpoints"', & 41 | required=.false., act='store_true', def='.false.', error=lo_status) 42 | if (lo_status .ne. 0) stop 43 | call cli%get(switch='--qpoint_grid', val=opts%qgrid) 44 | call cli%get(switch='--meshtype', val=opts%meshtype) 45 | call cli%get(switch='--readqpoints', val=opts%readqpointsfromfile) 46 | end subroutine 47 | 48 | end module 49 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing 2 | === 3 | 4 | When contributing to this repository, please first discuss the change you wish to make via issue, email, slack, or any other method with the maintainers of this repository. This will make life easier for everyone. 5 | 6 | ## Report Issues 7 | 8 | Please use the [issue tracker](https://github.com/tdep-developers/tdep/issues) to report issues. Please try to answer these questions: 9 | 10 | - Has this issue been discussed before? Please have a quick look at the existing issues. If not: 11 | - What is the issue? What is the expected behavior? 12 | - Is the problem reproducible? Please provide a _minimal_ example. 13 | 14 | 15 | ## Contribute Code via Pull Request 16 | 17 | In order to contribute code to `TDEP`, please follow the usual steps for [preparing and creating a pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request) via your own [fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/about-forks). A few remarks regarding our guidelines for code and code style: 18 | 19 | - Some of us use [`fprettify`](https://github.com/pseewald/fprettify) to format the code, the respective command is: 20 | ```bash 21 | fprettify -i 4 -l 500 --disable-indent-mod file.f90 22 | ``` 23 | 24 | This will format the code with an indent (`-i`) of 4 characters, without enforcing line breaks (`-l 500` allows up to 500 characters per line - please use less.) 25 | 26 | - Please _document_ and _test_ your changes by providing an example in the [`./examples`](./examples) or [`./tests`](./tests) folder. -------------------------------------------------------------------------------- /src/libflap/LICENSE.bsd-2.md: -------------------------------------------------------------------------------- 1 | Simplified BSD License 2 | ====================== 3 | 4 | Copyright © 2015, Stefano Zaghi 5 | 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, this 12 | list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | The views and conclusions contained in the software and documentation are those 29 | of the authors and should not be interpreted as representing official policies, 30 | either expressed or implied, of the FreeBSD Project. 31 | -------------------------------------------------------------------------------- /docs/program/dump_dynamical_matrices.md: -------------------------------------------------------------------------------- 1 | 2 | ### Short description 3 | 4 | Small utility to extract the dynamical matrices from TDEP, in formats readable by other codes. For the moment the ABINIT DDB format is supported. 5 | 6 | ### Command line options: 7 | 8 | 9 | 10 | 11 | Optional switches: 12 | 13 | * `--qpoint_grid value#1 value#2 value#3`, `-qg value#1 value#2 value#3` 14 | default value 26 26 26 15 | Density of q-point mesh for Brillouin zone integrations. 16 | 17 | * `--meshtype value, for value in: 1,2,3,4` 18 | default value 1 19 | Type of q-point mesh. 1 Is a Monkhorst-Pack mesh, 2 an FFT mesh and 3 my fancy wedge-based mesh with approximately the same density the grid-based meshes. 4 build the commensurate mesh of an approximately cubic supercell. 20 | 21 | * `--readqpoints` 22 | default value .false. 23 | Instead of generating a q-mesh, read it in fractional coordinates from a file called "infile.dynmatqpoints" 24 | 25 | * `--help`, `-h` 26 | Print this help message 27 | 28 | * `--version`, `-v` 29 | Print version 30 | 31 | ### Examples 32 | 33 | `dump_dynamical_matrices` 34 | 35 | ## Long summary 36 | 37 | This utility takes the infile.forceconstant hdf5 file, reads it in and converts it to reciprocal space dynamical matrices, then dumps these on a set of q points, either a regular grid or a set of user selected points. The goal is to take renormalized high T TDEP phonon frequencies and eigenvectors and re-use them in other contexts. 38 | 39 | 40 | ### Input files 41 | 42 | * [infile.forceconstant](../files.md#infile.forceconstant) 43 | 44 | ### Output files 45 | 46 | #### `outfile.many_dynamical_matrices_DDB` 47 | 48 | 49 | -------------------------------------------------------------------------------- /tests/README.md: -------------------------------------------------------------------------------- 1 | Test suite 2 | === 3 | 4 | ## Create test files for all binaries 5 | 6 | ```bash 7 | make testfiles 8 | ``` 9 | 10 | will run each TDEP binary from the most recent TDEP build in `../bin` in the specific folder, and create the corresponding output. Your `PATH` is modified by `00-set_path.sh` to make sure that you are not accidentally running binaries from a previous TDEP build. 11 | 12 | ## Check all outputs 13 | 14 | To check the files that were created against reference data, please run 15 | 16 | ```bash 17 | make test 18 | ``` 19 | 20 | This will run python scripts in each folder to check the produced output. **Please note that this requires some python dependencies which you find in `requirements.txt` and install via `pip install -r requirements.txt`**. 21 | 22 | Run 23 | 24 | ```bash 25 | make all 26 | ``` 27 | 28 | to run everything. 29 | 30 | ## Clean up 31 | 32 | Use 33 | 34 | ```bash 35 | make clean 36 | ``` 37 | 38 | to clean test files. 39 | 40 | ## Reference files 41 | 42 | Were created with TDEP commit `8c01e0343e4098f1d160efc141f8af6ae7f54941` on a macbook with M1 chip. 43 | 44 | ## Known issues 45 | 46 | - Errors like 47 | ``` 48 | atomic_distribution/test_atomic_distribution.py::test_hdf5 49 | :241: RuntimeWarning: numpy.ndarray size changed, may indicate binary incompatibility. Expected 16 from C header, got 96 from PyObject 50 | ``` 51 | 52 | hint towards compatibility issues in your python environment. **They are unrelated to TDEP.** 53 | 54 | ## Optional tests 55 | 56 | There are optional tests in `./optional` for binaries that require extra steps to compile. These tests are ignored per default. The test mechanism to test these optional binaries is the same. 57 | -------------------------------------------------------------------------------- /src/thermal_conductivity_2023/Makefile: -------------------------------------------------------------------------------- 1 | include Makefile.inc 2 | CODE = thermal_conductivity_2023 3 | PROG = ../../build/$(CODE)/$(CODE) 4 | OBJECT_PATH=../../build/$(CODE)/ 5 | 6 | OBJS = \ 7 | $(OBJECT_PATH)main.o\ 8 | $(OBJECT_PATH)options.o\ 9 | $(OBJECT_PATH)scatteringstrengths.o\ 10 | $(OBJECT_PATH)pbe.o\ 11 | $(OBJECT_PATH)phononevents.o\ 12 | $(OBJECT_PATH)mfp.o 13 | 14 | LPATH = -L../../lib $(blaslapackLPATH) $(incLPATHmpi) $(incLPATHhdf) 15 | IPATH = -I../../inc/libolle -I../../inc/libflap $(blaslapackIPATH) $(incIPATHmpi) $(incIPATHhdf) 16 | LIBS = ../../lib/libolle.a -lflap $(blaslapackLIBS) $(incLIBSmpi) $(incLIBShdf) 17 | 18 | #OPT = -O0 -fbacktrace -fcheck=all -finit-real=nan -finit-derived 19 | F90 = $(FC) $(LPATH) $(IPATH) $(MODULE_FLAG) $(OBJECT_PATH) #$(warnings_gcc) 20 | F90FLAGS = $(OPT) $(MODS) $(LIBS) 21 | 22 | all: $(PROG) 23 | 24 | $(PROG): $(OBJS) 25 | $(F90) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) 26 | 27 | clean: 28 | rm -f $(PROG) $(OBJS) $(OBJECT_PATH)*.mod 29 | 30 | $(OBJECT_PATH)main.o: \ 31 | $(OBJECT_PATH)options.o\ 32 | $(OBJECT_PATH)scatteringstrengths.o\ 33 | $(OBJECT_PATH)pbe.o\ 34 | $(OBJECT_PATH)phononevents.o\ 35 | $(OBJECT_PATH)mfp.o 36 | $(F90) $(OPT) $(F90FLAGS) -c main.f90 $(LIBS) -o $@ 37 | $(OBJECT_PATH)scatteringstrengths.o: $(OBJECT_PATH)phononevents.o 38 | $(F90) $(OPT) $(F90FLAGS) -c scatteringstrengths.f90 $(LIBS) -o $@ 39 | $(OBJECT_PATH)pbe.o: $(OBJECT_PATH)phononevents.o 40 | $(F90) $(OPT) $(F90FLAGS) -c pbe.f90 $(LIBS) -o $@ 41 | $(OBJECT_PATH)phononevents.o: 42 | $(F90) $(OPT) $(F90FLAGS) -c phononevents.f90 $(LIBS) -o $@ 43 | $(OBJECT_PATH)mfp.o: 44 | $(F90) $(OPT) $(F90FLAGS) -c mfp.f90 $(LIBS) -o $@ 45 | $(OBJECT_PATH)options.o: 46 | $(F90) $(OPT) $(F90FLAGS) -c options.f90 $(LIBS) -o $@ 47 | 48 | -------------------------------------------------------------------------------- /.github/important_settings.generic: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # A central place to put all the important paths. You probably have to modify this to make things work. 3 | 4 | # the fortran compiler 5 | FORTRAN_COMPILER="mpifort" 6 | # required compiler flags 7 | FCFLAGS="-ffree-line-length-none -std=gnu -cpp -fallow-argument-mismatch" 8 | # extra flags, for debugging and such 9 | FCFLAGS_EXTRA="" 10 | 11 | # optimization stuff. Go all in, sometimes 12 | OPTIMIZATION_LEVEL="-O3" 13 | OPTIMIZATION_SENSITIVE="-O0" 14 | 15 | # the flag that sets the default real to a double. 16 | DOUBLE_FLAG= # "-fdefault-real-8" 17 | # The flag that tells the compiler where to put .o and .mod files. 18 | MODULE_FLAG="-J" 19 | 20 | # These are the BLAS/LAPACK libraries. On OSX with gfortran, use the built-in 'framework accelerate' 21 | 22 | # -> exported outside 23 | # PATH_LIB="/usr/lib/x86_64-linux-gnu" 24 | PATH_INC="/usr/include" 25 | PATH_TO_BLASLAPACK_LIB="-L/$PATH_LIB" 26 | PATH_TO_BLASLAPACK_INC="-I/$PATH_INC" 27 | BLASLAPACK_LIBS="-lblas -llapack -lscalapack-openmpi" 28 | 29 | # I use fftw for Fourier transforms. 30 | PATH_TO_FFTW_LIB="-L/$PATH_LIB" 31 | PATH_TO_FFTW_INC="-I/$PATH_INC" 32 | FFTW_LIBS="-lfftw3" 33 | 34 | # I also use HDF5 every now and then 35 | PATH_TO_HDF5_LIB="-L/$PATH_LIB/hdf5/openmpi/" 36 | PATH_TO_HDF5_INC="-I/$PATH_INC/hdf5/openmpi/" 37 | HDF5_LIBS="-lhdf5 -lhdf5_fortran" 38 | 39 | USECGAL=no 40 | 41 | # some less important things 42 | # the header to put in python scripts. 43 | PYTHONHEADER="#!/usr/bin/env python" 44 | 45 | # Which gnuplot terminal to use by default. 46 | # Choices: aqua, qt, wxt 47 | GNUPLOTTERMINAL="qt" 48 | 49 | # Precompiler flags. Selecting default gnuplot terminal, and make the progressbars work. 50 | PRECOMPILER_FLAGS="-DGP${GNUPLOTTERMINAL} -Dclusterprogressbar" 51 | 52 | -------------------------------------------------------------------------------- /examples/build/important_settings.dardel: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This is on the PDC computer Dardel and this should work as of Jan 2022 4 | # 5 | 6 | # consider to choose specific module versions 7 | module swap PrgEnv-cray/8.2.0 PrgEnv-gnu/8.2.0 8 | module load cray-hdf5 9 | module load cray-fftw 10 | 11 | # the fortran compiler 12 | FORTRAN_COMPILER="ftn" 13 | # OPTIMIZATION_LEVEL="-O0" 14 | OPTIMIZATION_LEVEL="-O3 -march=znver2 -mtune=znver2 -mfma -mavx2 -m3dnow -fomit-frame-pointer" 15 | 16 | # the flag that sets the default real to a double. 17 | DOUBLE_FLAG="-fdefault-real-8" 18 | # The flag that tells the compiler where to put .o and .mod files. 19 | MODULE_FLAG="-J" 20 | 21 | # Precompiler flags. Selecting default gnuplot terminal, and makes the progressbars work. 22 | PRECOMPILER_FLAGS="-DGP${GNUPLOTTERMINAL} -Dclusterprogressbar" 23 | # PRECOMPILER_FLAGS="-DGP${GNUPLOTTERMINAL} -Dgfortranprogressbar" 24 | 25 | # flags for the fortran compiler to make it play nice. 26 | FCFLAGS="-ffree-line-length-none -std=f2008 -cpp -fallow-argument-mismatch -fopenmp" 27 | 28 | # Which gnuplot terminal to use by default. 29 | GNUPLOTTERMINAL="qt" 30 | 31 | # The following are already linked through the PrgEnv 32 | # BLAS/LAPACK 33 | PATH_TO_BLASLAPACK_LIB="" 34 | PATH_TO_BLASLAPACK_INC="" 35 | BLASLAPACK_LIBS="" 36 | 37 | # fftw 38 | PATH_TO_FFTW_LIB="" 39 | PATH_TO_FFTW_INC="" 40 | FFTW_LIBS="" 41 | 42 | # MPI stuff 43 | PATH_TO_MPI_LIB="" 44 | PATH_TO_MPI_INC="" 45 | MPI_LIBS="" 46 | 47 | # hdf5 stuff 48 | PATH_TO_HDF5_LIB="" 49 | PATH_TO_HDF5_INC="" 50 | HDF5_LIBS="" # "-lhdf5 -lhdf5_fortran" 51 | 52 | # Now I also need a C-compiler 53 | C_COMPILER="cc" 54 | 55 | # the header to put in python scripts. 56 | PYTHONHEADER="#!/usr/bin/python" 57 | # If you want to try and use CGAL. 58 | USECGAL="no" 59 | 60 | -------------------------------------------------------------------------------- /src/libolle/cgal_chull2.cc: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | // ok, no idea what any of this means. 7 | typedef CGAL::Exact_predicates_inexact_constructions_kernel K; 8 | typedef K::Point_2 Point_2; 9 | // just for debugging 10 | using std::cout; 11 | using std::endl; 12 | 13 | // this makes it a C wrapper 14 | extern "C"{ 15 | // calculate the convex hull of a set of 2D points 16 | void lo_cgal_chull2(const int &np,const double* r,int &nphull, double *&rhull){ 17 | 18 | // Now I have to stuff these points into something that CGAL likes 19 | Point_2 *points_in_cgal_format; 20 | points_in_cgal_format = new Point_2[np]; 21 | int l=0; 22 | for(int j=0;j 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | // ok, no idea what any of this means. 8 | typedef CGAL::Exact_predicates_inexact_constructions_kernel K; 9 | typedef CGAL::Polyhedron_3 Polyhedron_3; 10 | typedef K::Point_3 Point_3; 11 | // just for debugging 12 | using std::cout; 13 | using std::endl; 14 | 15 | // this makes it a C wrapper 16 | extern "C"{ 17 | // calculate the convex hull of a set of 2D points 18 | void lo_cgal_chull3(const int &np,const double* r,int &nphull, double *&rhull){ 19 | 20 | // Stuff the points into an iterator, whatever that is. 21 | std::vector points; 22 | // Stuff the points into this vector 23 | int l=0; 24 | for(int j=0;jpoint().x(); 41 | l++; rhull[l]=vert->point().y(); 42 | l++; rhull[l]=vert->point().z(); 43 | } 44 | // Some cleanup perhaps 45 | //poly.destroy(); 46 | // delete points 47 | // delete poly 48 | } 49 | } 50 | 51 | -------------------------------------------------------------------------------- /.github/important_settings.x86_64: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # A central place to put all the important paths. You probably have to modify this to make things work. 3 | 4 | # the fortran compiler 5 | FORTRAN_COMPILER="mpifort" 6 | # required compiler flags 7 | FCFLAGS="-ffree-line-length-none -std=gnu -cpp -fallow-argument-mismatch" 8 | # extra flags, for debugging and such 9 | FCFLAGS_EXTRA="" 10 | 11 | # optimization stuff. Go all in, sometimes 12 | OPTIMIZATION_LEVEL="-O3" 13 | OPTIMIZATION_SENSITIVE="-O0" 14 | 15 | # the flag that sets the default real to a double. 16 | DOUBLE_FLAG= # "-fdefault-real-8" 17 | # The flag that tells the compiler where to put .o and .mod files. 18 | MODULE_FLAG="-J" 19 | 20 | # These are the BLAS/LAPACK libraries. On OSX with gfortran, use the built-in 'framework accelerate' 21 | PATH_LIB="/usr/lib/x86_64-linux-gnu" 22 | PATH_INC="/usr/include" 23 | PATH_TO_BLASLAPACK_LIB="-L/$PATH_LIB" 24 | PATH_TO_BLASLAPACK_INC="-I/$PATH_INC" 25 | BLASLAPACK_LIBS="-lblas -llapack -lscalapack-openmpi" 26 | 27 | # I use fftw for Fourier transforms. 28 | PATH_TO_FFTW_LIB="-L/$PATH_LIB" 29 | PATH_TO_FFTW_INC="-I/$PATH_INC" 30 | FFTW_LIBS="-lfftw3" 31 | 32 | # we use mpifort so not needed 33 | # PATH_TO_MPI_LIB="-L/usr/lib/x86_64-linux-gnu" 34 | # PATH_TO_MPI_INC="-I/$PATH_INC" 35 | # MPI_LIBS="-lmpi_mpifh -lmpi" 36 | 37 | # I also use HDF5 every now and then 38 | PATH_TO_HDF5_LIB="-L/usr/lib/x86_64-linux-gnu/hdf5/openmpi/" 39 | PATH_TO_HDF5_INC="-I/usr/include/hdf5/openmpi/" 40 | HDF5_LIBS="-lhdf5 -lhdf5_fortran" 41 | 42 | USECGAL=no 43 | 44 | # some less important things 45 | # the header to put in python scripts. 46 | PYTHONHEADER="#!/usr/bin/env python" 47 | 48 | # Which gnuplot terminal to use by default. 49 | # Choices: aqua, qt, wxt 50 | GNUPLOTTERMINAL="qt" 51 | 52 | # Precompiler flags. Selecting default gnuplot terminal, and make the progressbars work. 53 | PRECOMPILER_FLAGS="-DGP${GNUPLOTTERMINAL} -Dclusterprogressbar" 54 | 55 | -------------------------------------------------------------------------------- /src/atomic_distribution/Makefile: -------------------------------------------------------------------------------- 1 | include Makefile.inc 2 | CODE = atomic_distribution 3 | PROG = ../../build/$(CODE)/$(CODE) 4 | OBJECT_PATH=../../build/$(CODE)/ 5 | 6 | OBJS = $(OBJECT_PATH)main.o $(OBJECT_PATH)options.o \ 7 | $(OBJECT_PATH)pairmapping.o $(OBJECT_PATH)pair_distribution.o $(OBJECT_PATH)mean_square_displacement.o \ 8 | $(OBJECT_PATH)diffraction.o 9 | 10 | LPATH = -L../../lib $(blaslapackLPATH) $(incLPATHhdf) $(incLPATHfft) $(incLPATHmpi) 11 | IPATH = -I../../inc/libolle -I../../inc/libflap $(blaslapackIPATH) $(incIPATHhdf) $(incIPATHfft) $(incIPATHmpi) 12 | LIBS = ../../lib/libolle.a -lflap $(blaslapackLIBS) $(incLIBShdf) $(incLIBSfft) $(incLIBSmpi) 13 | 14 | #OPT = -O0 -fcheck=all -fbacktrace -finit-real=nan -finit-derived -fmax-errors=10 #-Wall 15 | F90 = $(FC) $(LPATH) $(IPATH) $(MODULE_FLAG) $(OBJECT_PATH) #$(warnings_gcc) 16 | F90FLAGS = $(OPT) $(MODS) $(LIBS) 17 | 18 | all: $(PROG) 19 | 20 | $(PROG): $(OBJS) 21 | $(F90) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) 22 | 23 | clean: 24 | rm -f $(PROG) $(OBJS) $(OBJECT_PATH)*.mod 25 | 26 | $(OBJECT_PATH)main.o: main.f90 $(OBJECT_PATH)options.o $(OBJECT_PATH)pairmapping.o $(OBJECT_PATH)pair_distribution.o $(OBJECT_PATH)mean_square_displacement.o $(OBJECT_PATH)diffraction.o 27 | $(F90) $(F90FLAGS) -c main.f90 $(LIBS) -o $@ 28 | $(OBJECT_PATH)pair_distribution.o: pair_distribution.f90 $(OBJECT_PATH)pairmapping.o 29 | $(F90) $(F90FLAGS) -c pair_distribution.f90 $(LIBS) -o $@ 30 | $(OBJECT_PATH)mean_square_displacement.o: mean_square_displacement.f90 $(OBJECT_PATH)pairmapping.o 31 | $(F90) $(F90FLAGS) -c mean_square_displacement.f90 $(LIBS) -o $@ 32 | $(OBJECT_PATH)diffraction.o: diffraction.f90 $(OBJECT_PATH)pairmapping.o 33 | $(F90) $(F90FLAGS) -c diffraction.f90 $(LIBS) -o $@ 34 | $(OBJECT_PATH)pairmapping.o: pairmapping.f90 35 | $(F90) $(F90FLAGS) -c pairmapping.f90 $(LIBS) -o $@ 36 | $(OBJECT_PATH)options.o: options.f90 37 | $(F90) $(F90FLAGS) -c options.f90 $(LIBS) -o $@ 38 | -------------------------------------------------------------------------------- /src/manual/index.md: -------------------------------------------------------------------------------- 1 | title: Manual 2 | author: Olle Hellman 3 | 4 | #### Getting started 5 | 6 | To get started, make sure you meet the [dependencies and install](0_installation.html) everything. While things are compiling, it might be a good idea to familarize yourself with the literature, starting with a shameless plug for my papers: 7 | 8 | * [Hellman, O., Abrikosov, I. A., & Simak, S. I. (2011). Lattice dynamics of anharmonic solids from first principles. Physical Review B, 84(18), 180301.](http://doi.org/10.1103/PhysRevB.84.180301) 9 | 10 | * [Hellman, O. & Abrikosov, I. A. (2013). Temperature-dependent effective third-order interatomic force constants from first principles. Physical Review B, 88(14), 144301.](http://doi.org/10.1103/PhysRevB.88.144301) 11 | 12 | * [Hellman, O., Steneteg, P., Abrikosov, I. A., & Simak, S. I. (2013). Temperature dependent effective potential method for accurate free energy calculations of solids. Physical Review B, 87(10), 104111.](http://doi.org/10.1103/PhysRevB.87.104111) 13 | 14 | This provides background, but does not accurately reflect all the capabilities of this software package. 15 | 16 | #### Usage 17 | 18 | This software package consist of several programs, meant to be chained together into workflows, depending on property you are interested in. Before trying anything too complicated, make sure you start with the [tutorial](workflows/minimal_example_1.html), everything named *minimal example*. The descriptions of each program serves as both reference and theoretical background. For things to make sense, read them in this order: 19 | 20 | 1. [extract forceconstants](../program/extract_forceconstants.html) 21 | 2. [phonon dispersion relations](../program/phonon_dispersion_relations.html) 22 | 3. [lineshape](../program/lineshape.html) 23 | 4. [thermal conductivity](../program/thermal_conductivity.html) 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/extract_forceconstants/make.log: -------------------------------------------------------------------------------- 1 | gfortran-12 -ffree-line-length-none -std=f2008 -cpp -fallow-argument-mismatch -DGPaqua -Dclusterprogressbar -L../../lib -L/Users/flokno/local/hdf5-1.12.2/build_2022_11/lib -L/opt/homebrew/lib -I../../inc/libolle -I../../inc/libflap -L/Users/flokno/local/hdf5-1.12.2/build_2022_11/lib -I/opt/homebrew/include -J ../../build/extract_forceconstants/ -O3 -lolle -lflap -framework accelerate -I/Users/flokno/local/hdf5-1.12.2/build_2022_11/include -lhdf5 -lhdf5_fortran -lmpi_mpifh -lmpi -c options.f90 -lolle -lflap -framework accelerate -I/Users/flokno/local/hdf5-1.12.2/build_2022_11/include -lhdf5 -lhdf5_fortran -lmpi_mpifh -lmpi -o ../../build/extract_forceconstants/options.o 2 | gfortran-12 -ffree-line-length-none -std=f2008 -cpp -fallow-argument-mismatch -DGPaqua -Dclusterprogressbar -L../../lib -L/Users/flokno/local/hdf5-1.12.2/build_2022_11/lib -L/opt/homebrew/lib -I../../inc/libolle -I../../inc/libflap -L/Users/flokno/local/hdf5-1.12.2/build_2022_11/lib -I/opt/homebrew/include -J ../../build/extract_forceconstants/ -O3 -lolle -lflap -framework accelerate -I/Users/flokno/local/hdf5-1.12.2/build_2022_11/include -lhdf5 -lhdf5_fortran -lmpi_mpifh -lmpi -c main.f90 -lolle -lflap -framework accelerate -I/Users/flokno/local/hdf5-1.12.2/build_2022_11/include -lhdf5 -lhdf5_fortran -lmpi_mpifh -lmpi -o ../../build/extract_forceconstants/main.o 3 | gfortran-12 -ffree-line-length-none -std=f2008 -cpp -fallow-argument-mismatch -DGPaqua -Dclusterprogressbar -L../../lib -L/Users/flokno/local/hdf5-1.12.2/build_2022_11/lib -L/opt/homebrew/lib -I../../inc/libolle -I../../inc/libflap -L/Users/flokno/local/hdf5-1.12.2/build_2022_11/lib -I/opt/homebrew/include -J ../../build/extract_forceconstants/ -o ../../build/extract_forceconstants/extract_forceconstants ../../build/extract_forceconstants/main.o ../../build/extract_forceconstants/options.o -lolle -lflap -framework accelerate -I/Users/flokno/local/hdf5-1.12.2/build_2022_11/include -lhdf5 -lhdf5_fortran -lmpi_mpifh -lmpi 4 | -------------------------------------------------------------------------------- /src/samples_from_md/manual.md: -------------------------------------------------------------------------------- 1 | 2 | ### Longer summary 3 | 4 | Ab initio molecular dynamics are expensive calculations. There will be a tradeoff between numerical precision and the number of timesteps. To work around this, you can run the MD with rather low precision and gather statistics. Then, from the long simulation, choose a set of uncorrelated configurations and recalculate these with high precision. 5 | 6 | From these low accuracy calculations we choose a set of $n$ uncorrelated samples and correct scalar parameter $a$ as 7 | 8 | $$ 9 | \begin{equation} 10 | a = + \frac{1}{n}\sum_{i=1}^n a^h_i-a_i^l, 11 | \end{equation} 12 | $$ 13 | 14 | where $a^l$ are the low accuracy calculations and $a^h$ are calculations done with high accuracy. This exploits the fact that most omissions of numerical accuracy, such as basis set and k-point selection, lead to additive errors. This technique is well suited to determine the interatomic force constants and resulting thermodynamic/transport properties with high accuracy. 15 | 16 | This code selects a choice of uncorrelated samples from BOMD via a Monte-Carlo algorithm, assuring the selection is not biased. We start with a calculation of average potential $E_p$, kinetic energies $E_k$, and their standard deviation. We check the distance between samples assuring that chosen samples are not temporally adjacent. The results of this procedure is written in output files (`outfile.stat_sample`). The average values and distance between selected points depend on the number of desired samples. 17 | 18 | ### Input files 19 | 20 | * [infile.ucposcar](../files.md#infile.ucposcar) 21 | * [infile.ssposcar](../files.md#infile.ssposcar) 22 | * [infile.meta](../files.md#infile.meta) 23 | * [infile.stat](../files.md#infile.stat) 24 | * [infile.positions](../files.md#infile.positions) 25 | * [infile.forces](../files.md#infile.forces) 26 | 27 | ### Output files 28 | 29 | This code will generate a series of structures in the specified output format. 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/libolle/cgal_deltri2.cc: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | typedef CGAL::Exact_predicates_inexact_constructions_kernel K; 8 | typedef CGAL::Triangulation_vertex_base_with_info_2 Vb; 9 | typedef CGAL::Triangulation_data_structure_2 Tds; 10 | typedef CGAL::Delaunay_triangulation_2 Delaunay; 11 | typedef CGAL::Triangle_2 Triangle; 12 | typedef K::Point_2 Point_2; 13 | 14 | using std::cout; 15 | using std::endl; 16 | 17 | extern "C"{ 18 | // Calculate the Delaunay triangulation of a set of 2D points. 19 | // returns an array of triangles, defined as indices 20 | void lo_cgal_deltri2(const int &np, const double *r, int &ntri, int *&tri, double *&triarea){ 21 | // I think this is a vector with points and associated indices. 22 | std::vector< std::pair > points; 23 | int l=0; 24 | for(int j=0;jvertex(j)->info()+1; 42 | } 43 | Triangle triangle = dt.triangle( fit ); 44 | ll++; 45 | triarea[ll]=triangle.area(); 46 | } 47 | // and now it should all be done! 48 | } 49 | } 50 | 51 | -------------------------------------------------------------------------------- /docs/program/phasespace_surface.md: -------------------------------------------------------------------------------- 1 | 2 | ### Short description 3 | 4 | Calculate the three-phonon scattering surface. 5 | 6 | ### Command line options: 7 | 8 | 9 | 10 | 11 | Optional switches: 12 | 13 | * `--qpoint value#1 value#2 value#3` 14 | default value 0 0 0 15 | Specify the q-point for which to calculate the scattering surface. 16 | 17 | * `--highsymmetrypoint value` 18 | default value none 19 | Same as above, but you can specify the label of a high-symmetry point instead, e.g. "X" or "L". 20 | 21 | * `--modespec value#1 [value#2...]` 22 | default value 1 2 3 0 1 100 23 | Specify which surfaces to look at. 6 integers per surface: band1 band2 band3 plus/minus color opacity. Modes go from 1 to number of bands. plus/minus is 0 for plus events 1 for minus. Color from 1-3, opacity from 0-100. 24 | 25 | * `--povray` 26 | default value .false. 27 | Write POV-Ray script for rendering. 28 | 29 | * `--intensities` 30 | default value .false. 31 | Calculate intensities (matrix elements) as well. 32 | 33 | * `--pv_theta_phi value#1 value#2` 34 | default value 20 30 35 | Povray specification, theta and phi angles (in degrees) deteriming camera location. 36 | 37 | * `--pv_quality value` 38 | default value 9 39 | Povray rendering quality, 1-9 where 1 is worst. 40 | 41 | * `--nband value` 42 | default value -1 43 | Specify first band index 44 | 45 | * `--qpoint_grid value#1 value#2 value#3`, `-qg value#1 value#2 value#3` 46 | default value 26 26 26 47 | Density of q-point mesh for Brillouin zone integrations. 48 | 49 | * `--readqmesh` 50 | default value .false. 51 | Read the q-point mesh from file. To generate a q-mesh file, see the genkpoints utility. 52 | 53 | * `--help`, `-h` 54 | Print this help message 55 | 56 | * `--version`, `-v` 57 | Print version 58 | ### Examples 59 | 60 | `phasespace_surface --highsymmetrypoint X` 61 | 62 | `phasespace_surface --qpoint 0.1 0.2 0.3` 63 | -------------------------------------------------------------------------------- /examples/build/important_settings.sigma: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # A central place to put all the important paths. You probably have to modify this to make 4 | # things work. 5 | 6 | # Sigma/Tetralith 2024: 7 | module load buildenv-intel/2023a-eb 8 | module load HDF5/1.12.2-hpc1 9 | 10 | # the header to put in python scripts. 11 | PYTHONHEADER="#!/bin/env python" 12 | 13 | # Which gnuplot terminal to use by default. 14 | GNUPLOTTERMINAL="wxt" # other options are "aqua" and "x11" 15 | 16 | # the fortran compiler 17 | FORTRAN_COMPILER="mpiifort" 18 | OPTIMIZATION_LEVEL="-O3 -xCORE-AVX512" # first time you try you might want to put this to -O0 to make things compile a little faster. 19 | #OPTIMIZATION_LEVEL="-O0 -check bounds -check uninit -check pointers -check stack -traceback -g -fpe0 -init=snan,arrays -warn all -warn stderrors -stand f08 -diag-disable 5268" 20 | 21 | # Extra options for the compiler to make it play nice 22 | FCFLAGS="-ip -fpp -fp-model precise -qmkl=cluster" 23 | 24 | # flag that specifies location of modules 25 | MODULE_FLAG="-module" 26 | 27 | # Precompiler flags. Selecting default gnuplot terminal, and makes the progressbars work. 28 | PRECOMPILER_FLAGS="-DGP${GNUPLOTTERMINAL} -Dclusterprogressbar" 29 | 30 | # you need BLAS and LAPACK 31 | PATH_TO_BLASLAPACK_LIB="" # "-L${MKLROOT}/lib/intel64" 32 | PATH_TO_BLASLAPACK_INC="" # "-I${MKLROOT}/include" 33 | BLASLAPACK_LIBS="" # "-lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lmkl_blacs_intelmpi_lp64 -lmkl_scalapack_lp64" 34 | 35 | # I need the fftw library 36 | PATH_TO_FFTW_LIB="" 37 | PATH_TO_FFTW_INC="" # -I${MKL_ROOT}/include/fftw" 38 | FFTW_LIBS="" 39 | 40 | # Also need MPI 41 | PATH_TO_MPI_LIB="" # "-L${I_MPI_ROOT}/intel64/lib" 42 | PATH_TO_MPI_INC="" # "-I${I_MPI_ROOT}/intel64/include" 43 | MPI_LIBS="" # "-lmpi -lmpifort" 44 | 45 | # And a c-compiler 46 | C_COMPILER="icc" 47 | 48 | # And HDF5 49 | PATH_TO_HDF5_LIB="-L${HDF5_DIR}/lib" 50 | PATH_TO_HDF5_INC="-I${HDF5_DIR}/include" 51 | HDF5_LIBS="-lhdf5 -lhdf5_fortran" 52 | 53 | # Optionally CGAL and FHI-Aims. You probably do not want that. 54 | USECGAL="no" 55 | USEAIMS="no" 56 | -------------------------------------------------------------------------------- /src/refine_structure/Makefile: -------------------------------------------------------------------------------- 1 | include Makefile.inc 2 | CODE = refine_structure 3 | PROG = ../../build/$(CODE)/$(CODE) 4 | OBJECT_PATH=../../build/$(CODE)/ 5 | 6 | OBJS = $(OBJECT_PATH)main.o\ 7 | $(OBJECT_PATH)refine.o\ 8 | $(OBJECT_PATH)options.o\ 9 | $(OBJECT_PATH)lo_spacegroup.o\ 10 | $(OBJECT_PATH)lo_spacegroup_genoperations.o\ 11 | $(OBJECT_PATH)lo_spacegroup_charactertable.o\ 12 | $(OBJECT_PATH)lo_spacegroup_applyoperation.o\ 13 | $(OBJECT_PATH)lo_spacegroup_helpers.o 14 | 15 | LPATH = -L../../lib $(blaslapackLPATH) $(incLPATHhdf) $(incLPATHmpi) 16 | IPATH = -I../../inc/libolle -I../../inc/libflap $(blaslapackIPATH) $(incIPATHhdf) $(incIPATHmpi) 17 | LIBS = ../../lib/libolle.a -lflap $(blaslapackLIBS) $(incLIBShdf) $(incLIBSmpi) 18 | 19 | #OPT = -Ofast 20 | F90 = $(FC) $(LPATH) $(IPATH) $(MODULE_FLAG) $(OBJECT_PATH) 21 | F90FLAGS = $(OPT) $(MODS) $(LIBS) 22 | 23 | all: $(PROG) 24 | 25 | $(PROG): $(OBJS) 26 | $(F90) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) 27 | 28 | clean: 29 | rm -f $(PROG) $(OBJS) *.mod 30 | 31 | .f90.o: 32 | $(F90) $(F90FLAGS) -c $< $(LIBS) 33 | 34 | $(OBJECT_PATH)main.o: $(OBJECT_PATH)options.o $(OBJECT_PATH)refine.o $(OBJECT_PATH)lo_spacegroup.o 35 | $(F90) $(F90FLAGS) -c main.f90 $(LIBS) -o $@ 36 | $(OBJECT_PATH)lo_spacegroup.o: 37 | $(F90) $(F90FLAGS) -c lo_spacegroup.f90 $(LIBS) -o $@ 38 | $(OBJECT_PATH)lo_spacegroup_genoperations.o: $(OBJECT_PATH)lo_spacegroup.o 39 | $(F90) $(F90FLAGS) -c lo_spacegroup_genoperations.f90 $(LIBS) -o $@ 40 | $(OBJECT_PATH)lo_spacegroup_applyoperation.o: $(OBJECT_PATH)lo_spacegroup.o 41 | $(F90) $(F90FLAGS) -c lo_spacegroup_applyoperation.f90 $(LIBS) -o $@ 42 | $(OBJECT_PATH)lo_spacegroup_charactertable.o: $(OBJECT_PATH)lo_spacegroup.o 43 | $(F90) $(F90FLAGS) -c lo_spacegroup_charactertable.f90 $(LIBS) -o $@ 44 | $(OBJECT_PATH)lo_spacegroup_helpers.o: $(OBJECT_PATH)lo_spacegroup.o 45 | $(F90) $(F90FLAGS) -c lo_spacegroup_helpers.f90 $(LIBS) -o $@ 46 | $(OBJECT_PATH)refine.o: $(OBJECT_PATH)lo_spacegroup.o 47 | $(F90) $(F90FLAGS) -c refine.f90 $(LIBS) -o $@ 48 | $(OBJECT_PATH)options.o: 49 | $(F90) $(F90FLAGS) -c options.f90 $(LIBS) -o $@ 50 | -------------------------------------------------------------------------------- /examples/build/important_settings.tetralith: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # A central place to put all the important paths. You probably have to modify this to make 4 | # things work. 5 | # 6 | # This is on Tetralith, and I have the following modules loaded: 7 | module load buildenv-intel/2023a-eb 8 | module load HDF5/1.12.2 9 | 10 | # the header to put in python scripts. 11 | PYTHONHEADER="#!/bin/env python" 12 | 13 | # Which gnuplot terminal to use by default. 14 | GNUPLOTTERMINAL="wxt" # other options are "aqua" and "x11" 15 | 16 | # the fortran compiler 17 | FORTRAN_COMPILER="mpiifort" 18 | OPTIMIZATION_LEVEL="-O3 -xHost" # first time you try you might want to put this to -O0 to make things compile a little faster. 19 | #OPTIMIZATION_LEVEL="-O0 -check bounds -check uninit -check pointers -check stack -traceback -g -fpe0 -init=snan,arrays -warn all -warn stderrors -stand f08 -diag-disable 5268" 20 | 21 | # Extra options for the compiler to make it play nice 22 | FCFLAGS="-fpp -fp-model precise" 23 | 24 | # flag that specifies location of modules 25 | MODULE_FLAG="-module" 26 | 27 | # Precompiler flags. Selecting default gnuplot terminal, and makes the progressbars work. 28 | PRECOMPILER_FLAGS="-DGP${GNUPLOTTERMINAL} -Dclusterprogressbar" 29 | 30 | # you need BLAS and LAPACK 31 | PATH_TO_BLASLAPACK_LIB="-L${MKLROOT}/lib/intel64" 32 | PATH_TO_BLASLAPACK_INC="-I${MKLROOT}/include/intel64/lp64 -I${MKLROOT}/include" 33 | BLASLAPACK_LIBS="-lmkl_scalapack_lp64 -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lmkl_blacs_intelmpi_ilp64" 34 | 35 | # I need the fftw library 36 | PATH_TO_FFTW_LIB="" 37 | PATH_TO_FFTW_INC="-I${MKL_ROOT}/include/fftw" 38 | FFTW_LIBS="" 39 | 40 | # Also need MPI 41 | PATH_TO_MPI_LIB="" # "-L${I_MPI_ROOT}/intel64/lib" 42 | PATH_TO_MPI_INC="" # "-I${I_MPI_ROOT}/intel64/include" 43 | MPI_LIBS="" # "-lmpi -lmpifort" 44 | 45 | # And a c-compiler 46 | C_COMPILER="icc" 47 | 48 | # And HDF5 49 | PATH_TO_HDF5_LIB="-L${HDF5_DIR}/lib" 50 | PATH_TO_HDF5_INC="-I${HDF5_DIR}/include" 51 | HDF5_LIBS="-lhdf5 -lhdf5_fortran" 52 | 53 | # Optionally CGAL and FHI-Aims. You probably do not want that. 54 | USECGAL="no" 55 | USEAIMS="no" 56 | -------------------------------------------------------------------------------- /src/manual/workflows/minimal_example_3.md: -------------------------------------------------------------------------------- 1 | title: Minimal example III 2 | author: Olle Hellman 3 | 4 | ### Fast stochastic calculations 5 | 6 | Initially, the TDEP method was based on sampling the correct region of phase space via ab initio molecular dynamics. Since then I have also been using stochastic methods of sampling phase space, essentially self-consistent phonons. 7 | 8 | @note I do have a formal derivation that minimizing the difference in forces and minimizing the error in free energy is equivalent, and that the former is just a very efficient way of realizing the latter. Should probably publish it in a paper before I publish it here though. 9 | 10 | The algorithm is simple: 11 | 12 | * Create a set of supercells that sample phase space from a set of phonons 13 | * Determine the effective harmonic Hamiltonian 14 | * With new phonons, create new supercells and repeat until convergence 15 | 16 | There are some subtleties here though. The first issue is where to start: since it is a self-consistent procedure the speed will depend on how close to the final answer the initial guess is. 17 | The second issue is about efficiency: how many configurations do you choose in each iteration, and is there a scheme to speed up convergence? If done right, stochastic calculations can be extremely efficient. If done wrong, not so much. 18 | 19 | In fact, for weakly anharmonic systems stochastic sampling can be faster than finite difference calculations or DFPT. The cost is linear in the number of Wyckoff positions, approximately. 20 | 21 | ## Geometric series 22 | 23 | I will start by describing the simplest possible scheme. It might not always be the fastest, but empirically I have found it to be very robust. For starters, prepare an empty folder that contain the unit cell. My suggestion is to use bcc Li as an example, mostly because DFT calculations of Li are fast, but also because it is anharmonic enough to not be completely trivial. 24 | 25 | 26 | 27 | (I suggest practicing on a simple metal, bcc Li is a great example) Build a supercell of around 100 atoms 28 | 29 | 30 | 31 | ## 32 | 33 | @todo Make example with classical potential? 34 | -------------------------------------------------------------------------------- /src/libolle/cgal_deltri3.cc: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | typedef CGAL::Exact_predicates_inexact_constructions_kernel K; 10 | typedef CGAL::Triangulation_vertex_base_with_info_3 Vb; 11 | typedef CGAL::Triangulation_data_structure_3 Tds; 12 | typedef CGAL::Delaunay_triangulation_3 Delaunay; 13 | typedef CGAL::Tetrahedron_3 Tetrahedron; 14 | typedef K::Point_3 Point_3; 15 | 16 | extern "C"{ 17 | // Calculate the Delaunay triangulation of a set of 3D points. 18 | // returns an array of triangles, defined as a triplet of indices to the original points 19 | void lo_cgal_deltri3(const int &np, const double *r, int &ntet, int *&tet, double *&tetvol){ 20 | // I think this is a vector with points and associated indices. 21 | std::vector< std::pair > points; 22 | // Stuff the points into this vector 23 | int l=0; 24 | for(int j=0;jvertex(j)->info()+1; 43 | } 44 | Tetrahedron tetr = dt.tetrahedron( fit ); 45 | ll++; 46 | tetvol[ll]=tetr.volume(); 47 | } 48 | // Find the adjacent tetrahedrons 49 | 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /tests/optional/phasespace_surface/test_phasespace_surface.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pathlib import Path 3 | 4 | parent = Path(__file__).parent 5 | folder = parent / "reference" 6 | 7 | 8 | def _read_file(file): 9 | data_plus = [] 10 | data_minus = [] 11 | with open(file, "r") as f: 12 | for line in f: 13 | if "... write nonzero phase spaces and scattering intensities" in line: 14 | break 15 | 16 | for line in f: 17 | if "plus" in line: 18 | _plus = True 19 | continue 20 | if "minus" in line: 21 | _plus = False 22 | continue 23 | if "All done" in line: 24 | return np.array(data_plus), np.array(data_minus) 25 | 26 | x1, x2, x3, x4, x5 = line.split() 27 | if _plus: 28 | data_plus.append([int(x1), int(x2), int(x3), int(x4), float(x5)]) 29 | else: 30 | data_minus.append([int(x1), int(x2), int(x3), int(x4), float(x5)]) 31 | 32 | 33 | def test_phasespace(file="phasespace_surface.log"): 34 | data_ref = _read_file(folder / file) 35 | data_new = _read_file(parent / file) 36 | 37 | err_msg = (parent / file).absolute() 38 | # 3 modes: should match exactly 39 | kw = {"err_msg": err_msg} 40 | np.testing.assert_allclose(data_ref[0][:, :3], data_new[0][:, :3], **kw) 41 | np.testing.assert_allclose(data_ref[1][:, :3], data_new[1][:, :3], **kw) 42 | 43 | # 4: number of points: should match up to 10% error 44 | rtol = 1 45 | kw = {"atol": 0, "rtol": rtol, "err_msg": err_msg} 46 | np.testing.assert_allclose(data_ref[0][:, 3], data_new[0][:, 3], **kw) 47 | np.testing.assert_allclose(data_ref[1][:, 3], data_new[1][:, 3], **kw) 48 | 49 | # 5: intensity: should match up to 0.01 50 | atol = 1e-2 51 | kw = {"atol": atol, "rtol": 0, "err_msg": err_msg} 52 | np.testing.assert_allclose(data_ref[0][:, 4], data_new[0][:, 4], **kw) 53 | np.testing.assert_allclose(data_ref[1][:, 4], data_new[1][:, 4], **kw) 54 | 55 | 56 | if __name__ == "__main__": 57 | test_phasespace() 58 | -------------------------------------------------------------------------------- /examples/build/important_settings.gfortran: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # A central place to put all the important paths. You probably have to modify this to make things work. 3 | 4 | # the fortran compiler 5 | FORTRAN_COMPILER="mpifort" 6 | # or 7 | # FORTRAN_COMPILER="gfortran" 8 | 9 | # required compiler flags 10 | FCFLAGS="-ffree-line-length-none -std=f2008 -cpp -fallow-argument-mismatch" 11 | 12 | # extra flags, for debugging and such 13 | FCFLAGS_EXTRA="" 14 | # FCFLAGS_EXTRA="-fbacktrace -fcheck=all -finit-real=nan -finit-derived -fmax-errors=10 --pedantic --warn-all" 15 | # FCFLAGS_EXTRA="-g -fbacktrace -fcheck=all -finit-real=nan -finit-derived -fmax-errors=10 --pedantic -Wall -Wextra -pedantic -Wcast-align -Wdisabled-optimization -Wmissing-include-dirs -Wshadow -Wunused -fdiagnostics-show-option -fcheck=all -Wstrict-overflow=0 -Wrealloc-lhs" 16 | 17 | # optimization stuff. Go all in, sometimes 18 | OPTIMIZATION_SENSITIVE="-O0" 19 | OPTIMIZATION_LEVEL="-O0" 20 | # later you want 21 | # OPTIMIZATION_LEVEL="-O3" 22 | 23 | # CHECK THESE: 24 | # the flag that sets the default real to a double. 25 | DOUBLE_FLAG="-fdefault-real-8" 26 | # The flag that tells the compiler where to put .o and .mod files. 27 | MODULE_FLAG="-J" 28 | 29 | # Which gnuplot terminal to use by default. 30 | # Choices: aqua, qt, wxt 31 | GNUPLOTTERMINAL="qt" 32 | 33 | # Precompiler flags. Selecting default gnuplot terminal, and make the progressbars work. 34 | PRECOMPILER_FLAGS="-DGP${GNUPLOTTERMINAL} -Dclusterprogressbar -DAGRESSIVE_SANITY" 35 | PRECOMPILER_FLAGS="-DGP${GNUPLOTTERMINAL} -Dclusterprogressbar" 36 | 37 | # These are the BLAS/LAPACK libraries. 38 | PATH_TO_BLASLAPACK_LIB="-L/usr/lib" 39 | PATH_TO_BLASLAPACK_INC="-I/usr/include" 40 | BLASLAPACK_LIBS="-llapack -lblas" 41 | 42 | # I use fftw for Fourier transforms. 43 | PATH_TO_FFTW_LIB="-L/usr/lib" 44 | PATH_TO_FFTW_INC="-I/usr/include" 45 | FFTW_LIBS="-lfftw3" 46 | 47 | # Also need MPI 48 | PATH_TO_MPI_LIB="-L/usr/lib" 49 | PATH_TO_MPI_INC="-I/usr/include" 50 | MPI_LIBS="-lmpi_mpifh -lmpi" 51 | 52 | # I also use HDF5 every now and then 53 | PATH_TO_HDF5_LIB="-L/usr/lib" 54 | PATH_TO_HDF5_INC="-I/usr/include" 55 | HDF5_LIBS="-lhdf5 -lhdf5_fortran" 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/lineshape/phonondamping_aux.f90: -------------------------------------------------------------------------------- 1 | submodule(phonondamping) phonondamping_aux 2 | !! Helper routines that did not fit elsewhere. Maybe deprecated. 3 | implicit none 4 | contains 5 | 6 | ! !> The magical thermal prefactor 7 | ! function thermal_pref(bigQ,eigenvector,uc,temperature,omega,sigma) result(pref) 8 | ! real(r8), dimension(3), intent(in) :: bigQ 9 | ! complex(r8), dimension(:), intent(in) :: eigenvector 10 | ! type(lo_crystalstructure), intent(in) :: uc 11 | ! real(r8), intent(in) :: temperature 12 | ! real(r8), intent(in) :: omega 13 | ! real(r8), dimension(:,:,:), intent(in) :: sigma 14 | ! real(r8) :: pref 15 | ! 16 | ! integer :: i 17 | ! complex(r8) :: c0,c1,c2 18 | ! real(r8) :: f1,xs,dw 19 | ! 20 | ! pref=1.0_r8 21 | ! ! Add the thermal factor 22 | ! pref=pref*(2*lo_planck(temperature,omega)+1.0_r8) 23 | ! 24 | ! ! Cross-product guy 25 | ! c2=0.0_r8 26 | ! do i=1,uc%na 27 | ! ! Grab the cross-section? 28 | ! xs=uc%inelastic_neutron_cross_section(i)*uc%invsqrtmass(i) 29 | ! ! Debye-Waller factor? 30 | ! dw=exp( -0.5_r8*dot_product(bigQ,matmul(sigma(:,:,i),bigQ))*lo_twopi**2 ) 31 | ! 32 | ! f1=dot_product(lo_twopi*bigQ,uc%rcart(:,i)) 33 | ! c0=cmplx( cos(f1), sin(f1) ,r8) 34 | ! c1=dot_product( lo_twopi*bigQ,eigenvector( (i-1)*3+1:i*3 ) ) 35 | ! c2=c2+c0*c1*xs 36 | ! enddo 37 | ! pref=pref*abs(conjg(c2)*c2) 38 | ! end function 39 | ! 40 | ! subroutine spectral_tau(omega,spectralfunction,temperature,tau) 41 | ! !> energy axis 42 | ! real(r8), dimension(:), intent(in) :: omega 43 | ! !> spectral function 44 | ! real(r8), dimension(:), intent(in) :: spectralfunction 45 | ! !> temperature 46 | ! real(r8), intent(in) :: temperature 47 | ! !> thermal conductivity? 48 | ! real(r8), intent(out) :: tau 49 | ! 50 | ! real(r8) :: n 51 | ! integer :: ie 52 | ! 53 | ! tau=0.0_r8 54 | ! do ie=2,size(omega) 55 | ! n=lo_planck(temperature,omega(ie)) 56 | ! tau=tau+n*(n+1)*(spectralfunction(ie)**2) 57 | ! enddo 58 | ! tau=tau*(omega(2)-omega(1)) 59 | ! end subroutine 60 | 61 | end submodule 62 | -------------------------------------------------------------------------------- /tests/atomic_distribution/reference/outfile.mean_square_displacement: -------------------------------------------------------------------------------- 1 | 0.0000000000E+00 0.1324324513E-01 0.7575131815E-02 0.5668113312E-02 2 | 0.1000000000E+01 0.1325716124E-01 0.6431467011E-02 0.6825694228E-02 3 | 0.2000000000E+01 0.1521220719E-01 0.8681552719E-02 0.6530654468E-02 4 | 0.3000000000E+01 0.1354675923E-01 0.7593830527E-02 0.5952928702E-02 5 | 0.4000000000E+01 0.1350535340E-01 0.7621549108E-02 0.5883804293E-02 6 | 0.5000000000E+01 0.1451778889E-01 0.7683050491E-02 0.6834738404E-02 7 | 0.6000000000E+01 0.1366543408E-01 0.7647978904E-02 0.6017455175E-02 8 | 0.7000000000E+01 0.1374110908E-01 0.7262810932E-02 0.6478298147E-02 9 | 0.8000000000E+01 0.1420842632E-01 0.7729059346E-02 0.6479366977E-02 10 | 0.9000000000E+01 0.1478612211E-01 0.7998269465E-02 0.6787852645E-02 11 | 0.1000000000E+02 0.1342004651E-01 0.7007244616E-02 0.6412801889E-02 12 | 0.1100000000E+02 0.1204463696E-01 0.6593592776E-02 0.5451044183E-02 13 | 0.1200000000E+02 0.1456863041E-01 0.8343406443E-02 0.6225223967E-02 14 | 0.1300000000E+02 0.1381476779E-01 0.7974751335E-02 0.5840016458E-02 15 | 0.1400000000E+02 0.1250360305E-01 0.6971732195E-02 0.5531870852E-02 16 | 0.1500000000E+02 0.1343391609E-01 0.7125686577E-02 0.6308229517E-02 17 | 0.1600000000E+02 0.1203339223E-01 0.6173066149E-02 0.5860326077E-02 18 | 0.1700000000E+02 0.1346966481E-01 0.7444351019E-02 0.6025313793E-02 19 | 0.1800000000E+02 0.1280969769E-01 0.6846304693E-02 0.5963392995E-02 20 | 0.1900000000E+02 0.1403983413E-01 0.8144062000E-02 0.5895772131E-02 21 | 0.2000000000E+02 0.1221906310E-01 0.6789029898E-02 0.5430033200E-02 22 | 0.2100000000E+02 0.1301751363E-01 0.6752937241E-02 0.6264576394E-02 23 | 0.2200000000E+02 0.1412698324E-01 0.6992694849E-02 0.7134288387E-02 24 | 0.2300000000E+02 0.1359467381E-01 0.7785864242E-02 0.5808809569E-02 25 | -------------------------------------------------------------------------------- /src/manual/workflows/minimal_example_5.md: -------------------------------------------------------------------------------- 1 | title: Minimal example V 2 | author: Olle Hellman 3 | 4 | ### Thermal conductivity 5 | 6 | @todo Introduction, say what papers to read and so on. 7 | 8 | @todo Specify what needs to exist 9 | 10 | @todo Switch to Si, makes more sense. 11 | 12 | Here we will reuse the data in `example_1_fcc_Al`. Copy the files to a new, clean folder, and repeat the steps from [the first tutorial](minimal_example_1.html) to generate second and third order force constants. 13 | 14 | Note that this example is for fcc Al. I chose that since with one atom per unit cell, the thermal conductivity calculations are really fast. Unfortunately, since thermal conductivity in Al is dominated by the electronic component, none of the values can be compared with anything in a meaningful way -- but all the procedures in this tutorial are valid for any compound. 15 | 16 | You should end up with (among other things) 17 | 18 | * [infile.ucposcar](../page/files.html#infile.ucposcar) 19 | * [infile.forceconstant](extract_forceconstants.html#infile.forceconstant) 20 | * [infile.forceconstant_thirdorder](extract_forceconstants.html#infile.forceconstant_thirdorder) 21 | 22 | This set of files is the minimum required to calculate thermal conductivity. 23 | 24 | ``` 25 | mpirun thermal_conductivity -qg 5 5 5 --temperature 300 26 | ``` 27 | 28 | and it should appear, rather quickly. Make yourself familiar with the options for [thermal conductivity](../../program/thermal_conductivity.html), there are quite a few. A series of temperatures can be calculated with 29 | 30 | ``` 31 | mpirun thermal_conductivity -qg 5 5 5 --temperature_range 10 1000 50 --logtempaxis 32 | ``` 33 | 34 | @todo Convergence with respect to q-point density. Point out that you have to plot with respect to 1/q, not q. 35 | 36 | @todo Think about different integration schemes. Per default, the scattering rates are integrated using the tetrahedron method.[^Lehmann1972] 37 | 38 | @todo Make them test tetrahedron vs gaussian. 39 | 40 | [^Lehmann1972]: [Lehmann, G., & Taut, M. (1972). On the Numerical Calculation of the Density of States and Related Properties. Physica Status Solidi (B), 54(2), 469–477.]( http://doi.org/10.1002/pssb.2220540211) 41 | -------------------------------------------------------------------------------- /src/libflap/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Olles makefile for FLAP. 3 | # 4 | # Computer dependent stuff 5 | include Makefile.inc 6 | 7 | PROGNAME=libflap 8 | 9 | OBJECT_PATH=../../build/libflap/ 10 | MODULE_PATH=../../inc/libflap/ 11 | DEST_PATH=../../lib/ 12 | 13 | #LPATH = $(blaslapackLPATH) 14 | #IPATH = $(blaslapackIPATH) 15 | #LIBS = $(blaslapackLIBS) 16 | 17 | FFLAGS = $(MODULE_FLAG) $(MODULE_PATH) 18 | #FFLAGS = $(OPT) $(MODULE_FLAG) $(MODULE_PATH) 19 | 20 | # Stuff that needs to be compiled 21 | OBJS = \ 22 | $(OBJECT_PATH)penf.o \ 23 | $(OBJECT_PATH)flap.o \ 24 | $(OBJECT_PATH)flap_command_line_argument_t.o \ 25 | $(OBJECT_PATH)flap_command_line_arguments_group_t.o \ 26 | $(OBJECT_PATH)flap_command_line_interface_t.o \ 27 | $(OBJECT_PATH)flap_object_t.o \ 28 | $(OBJECT_PATH)flap_utils_m.o 29 | 30 | # rules for the library 31 | $(DEST_PATH)libflap.a: $(OBJS) 32 | -rm $(DEST_PATH)libflap.a 33 | ar -rcs $(DEST_PATH)libflap.a $(OBJS); ranlib $(DEST_PATH)libflap.a 34 | 35 | # I did all the rules manually. Because I hate myself less than I hate make. 36 | $(OBJECT_PATH)penf.o: 37 | $(FC) $(FFLAGS) -c penf.F90 -o $@ 38 | $(OBJECT_PATH)flap_object_t.o: $(OBJECT_PATH)penf.o 39 | $(FC) $(FFLAGS) -c flap_object_t.f90 -o $@ 40 | $(OBJECT_PATH)flap_utils_m.o: $(OBJECT_PATH)penf.o 41 | $(FC) $(FFLAGS) -c flap_utils_m.f90 -o $@ 42 | $(OBJECT_PATH)flap_command_line_argument_t.o: $(OBJECT_PATH)penf.o $(OBJECT_PATH)flap_object_t.o $(OBJECT_PATH)flap_utils_m.o 43 | $(FC) $(FFLAGS) -c flap_command_line_argument_t.F90 -o $@ 44 | $(OBJECT_PATH)flap_command_line_arguments_group_t.o:\ 45 | $(OBJECT_PATH)flap_command_line_argument_t.o\ 46 | $(OBJECT_PATH)penf.o 47 | $(FC) $(FFLAGS) -c flap_command_line_arguments_group_t.f90 -o $@ 48 | $(OBJECT_PATH)flap_command_line_interface_t.o: $(OBJECT_PATH)penf.o $(OBJECT_PATH)flap_command_line_argument_t.o $(OBJECT_PATH)flap_command_line_arguments_group_t.o 49 | $(FC) $(FFLAGS) -c flap_command_line_interface_t.F90 -o $@ 50 | $(OBJECT_PATH)flap.o: $(OBJECT_PATH)flap_command_line_argument_t.o $(OBJECT_PATH)flap_command_line_arguments_group_t.o $(OBJECT_PATH)flap_command_line_interface_t.o 51 | $(FC) $(FFLAGS) -c flap.f90 -o $@ 52 | # 53 | clean: 54 | rm -rf $(OBJECT_PATH)*.o $(MODULE_PATH)*.mod 55 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # the binaries 3 | #src/autocorrelation/autocorrelation 4 | #src/classicalmd/classicalmd 5 | #src/initialize_md/initialize_md 6 | #src/mean_square_displacement/mean_square_displacement 7 | #src/phonon_dispersion_relations/phonon_dispersion_relations 8 | #src/phonon_linewidths/phonon_linewidths 9 | #src/lineshape/lineshape 10 | #src/initialize_md/initialize_md 11 | #src/samples_from_md/samples_from_md 12 | #src/probability_distribution/probability_distribution 13 | #src/thermal_conductivity/thermal_conductivity 14 | #src/pair_distribution_function/pair_distribution_function 15 | #src/figure_out_symmetry_things/figure_out_symmetry_things 16 | #src/generate_structure/generate_structure 17 | #src/autocorrelation/autocorrelation 18 | #src/small_hello_world/small_hello_world 19 | #src/crystal_structure_info/crystal_structure_info 20 | #src/extract_forceconstants/extract_forceconstants 21 | #src/fermisurface/fermisurface 22 | #src/fold_bands/fold_bands 23 | #src/unfold_arcs_data/unfold_arcs_data 24 | #src/generate_displacements/generate_displacements 25 | #src/fold_bands/fold_bands 26 | #src/elastic_constants/elastic_constants 27 | #src/unstable_extract_forceconstants_do_not_use/unstable_extract_forceconstants_do_not_use 28 | #src/vector_distribution/vector_distribution 29 | #src/remap_forceconstant/remap_forceconstants 30 | 31 | # directories not to look at 32 | bin/ 33 | lib/ 34 | inc/ 35 | doc/ 36 | man/ 37 | build/ 38 | 39 | Makefile.inc 40 | 41 | # things in the tests 42 | tests/test*/extract_forceconstants 43 | tests/test*/*.m 44 | tests/test*/disprel_xtck 45 | 46 | # things in the staging area 47 | staging/ 48 | 49 | # Coding 50 | .vscode 51 | *venv* 52 | tmp 53 | 54 | # Compiled Object files 55 | *.slo 56 | *.lo 57 | *.o 58 | *.a 59 | *.obj 60 | 61 | # Precompiled Headers 62 | *.gch 63 | *.pch 64 | 65 | # Compiled Dynamic libraries 66 | *.so 67 | *.dylib 68 | *.dll 69 | 70 | # Fortran module files 71 | *.mod 72 | 73 | 74 | # misc stupid things 75 | outfile.* 76 | mathoutfile.* 77 | *.swp 78 | bashrc_tdep 79 | important_settings 80 | *.png 81 | documentation_carousel.md 82 | 83 | # git 84 | **/gitinformation 85 | 86 | # Annoying OSX files 87 | .DS_Store 88 | fortls_debug.log 89 | 90 | __pycache__ 91 | -------------------------------------------------------------------------------- /docs/program/pack_simulation.md: -------------------------------------------------------------------------------- 1 | 2 | ### Short description 3 | 4 | Small utility to pack a simulation to hdf5. 5 | 6 | ### Command line options: 7 | 8 | 9 | 10 | 11 | Optional switches: 12 | 13 | * `--stride value`, `-s value` 14 | default value 1 15 | Pack every N configuration instead of all. 16 | 17 | * `--nrand value` 18 | default value -1 19 | Pack N random configurations instead of all. 20 | 21 | * `--temperature value` 22 | default value -1 23 | Override the simulation temperature. 24 | 25 | * `--variable_cell`, `-npt` 26 | default value .false. 27 | Make sure to store variable cell information. 28 | 29 | * `--magnetic_moments`, `-mag` 30 | default value .false. 31 | Make sure to store projected magnetic moments. 32 | 33 | * `--dielectric` 34 | default value .false. 35 | Make sure to store dielectric constant and Born charges. 36 | 37 | * `--molecular_dynamics`, `-md` 38 | default value .false. 39 | Make sure to specify that this is real molecular dynamics. 40 | 41 | * `--notidy` 42 | default value .false. 43 | Per default the simulation is cleaned, drift removed and so on. This switch skips that. 44 | 45 | * `--help`, `-h` 46 | Print this help message 47 | 48 | * `--version`, `-v` 49 | Print version 50 | ### Examples 51 | 52 | `pack_simulation` 53 | 54 | ## Long summary 55 | 56 | This utility takes the plain-text input files and packs them to hdf5. The options allow you to pack a subset and specify what information to include. The resulting output file can take the place of the regular input files. This is by no means a necessary tool, the main utility is reduced file size and increased io speed. 57 | 58 | ### Input files 59 | 60 | * [infile.ucposcar](../files.md#infile.ucposcar) 61 | * [infile.ssposcar](../files.md#infile.ucposcar) 62 | * [infile.positions](../files.md#infile.positions) 63 | * [infile.forces](../files.md#infile.forces) 64 | * [infile.stat](../files.md#infile.stat) 65 | * [infile.meta](../files.md#infile.meta) 66 | 67 | ### Output files 68 | 69 | #### `outfile.sim.hdf5` 70 | 71 | This is merely an archive that contains all the information in the input files but packed to a single file. For the casual use it has little benefit except using considerably less space. 72 | -------------------------------------------------------------------------------- /docs/program/refine_structure.md: -------------------------------------------------------------------------------- 1 | 2 | ### Short description 3 | 4 | Small utility to ensure that the input structure satisfies all symmetries to high precision. 5 | 6 | ### Command line options: 7 | 8 | 9 | 10 | 11 | Optional switches: 12 | 13 | * `--tolerance_lattice value`, `-tl value` 14 | default value 1E-5 15 | Tolerance for the lattice. 16 | 17 | * `--tolerance_internal value`, `-ti value` 18 | default value 1E-5 19 | Tolerance for internal degrees of freedom. 20 | 21 | * `--unitcell value`, `-uc value` 22 | default value infile.ucposcar 23 | Filename for the unitcell to refine. 24 | 25 | * `--supercell value`, `-ss value` 26 | default value none 27 | Filename for supercell to refine. 28 | 29 | * `--prototype value`, `-pf value` 30 | default value none 31 | Prototype unitcell where you know the symmetry is correct. 32 | 33 | * `--help`, `-h` 34 | Print this help message 35 | 36 | * `--version`, `-v` 37 | Print version 38 | ### Examples 39 | 40 | `refine_structure` 41 | 42 | ### Longer summary 43 | 44 | This is a utility to ensure that the symmetries of the crystal structure is satisfied to as high precision as possible. A vast majority of issues users experience, can be solved with this tool. 45 | 46 | In essence, it takes an input crystal structure that might be specified like this 47 | 48 | ``` 49 | hcp Fe 50 | 2.4 51 | 0.50000 -0.866025 0.00000 52 | 0.50000 0.866025 0.00000 53 | 0.00000 0.000000 1.63299 54 | Fe 55 | 2 56 | Direct 57 | 0.333333 0.66666 0.25000 58 | 0.666666 0.33333 0.75000 59 | ``` 60 | 61 | And returns 62 | 63 | ``` 64 | hcp Fe 65 | 2.399999720250 66 | 0.50000000000000 -0.86602540378444 0.00000000000000 67 | 0.50000000000000 0.86602540378444 0.00000000000000 68 | 0.00000000000000 0.00000000000000 1.63299057103649 69 | Fe 70 | 2 71 | Direct coordinates 72 | 0.33333333333333 0.66666666666667 0.25000000000000 site 1 species 1: Fe 73 | 0.66666666666667 0.33333333333333 0.75000000000000 site 2 species 1: Fe 74 | ``` 75 | 76 | !!! note 77 | Explain that we can use a prototype structure to determine the spacegroup, as in pick spacegroup from a unit cell I know is ok, and impose that on the current cell. 78 | 79 | 80 | -------------------------------------------------------------------------------- /mkdocs.yml: -------------------------------------------------------------------------------- 1 | site_name: TDEP 2 | 3 | repo_url: https://github.com/tdep-developers/tdep 4 | 5 | copyright: 'Copyright © 2023 Olle Hellman, Florian Knoop' 6 | 7 | theme: 8 | name: 'material' 9 | 10 | palette: 11 | primary: white 12 | accent: cyan 13 | logo: 'media/matematico_favicon.png' 14 | favicon: 'media/matematico_favicon.png' 15 | include_search_page: false 16 | features: 17 | - navigation.tabs 18 | - navigation.sticky 19 | - navigation.instant 20 | - navigation.indexes 21 | 22 | font: 23 | text: Inter 24 | code: 'Droid Sans Mono' 25 | 26 | nav: 27 | - Home: README.md 28 | # - Tutorial: 29 | # - Overview: manual/index.md 30 | - Programs: 31 | - program/README.md 32 | - Generate structure: program/generate_structure.md 33 | - Canonical configuration: program/canonical_configuration.md 34 | - Extract forceconstants: program/extract_forceconstants.md 35 | - Phonon dispersion relations: program/phonon_dispersion_relations.md 36 | - Thermal conductivity 2023: program/thermal_conductivity_2023.md 37 | - Thermal conductivity: program/thermal_conductivity.md 38 | - Lineshape: program/lineshape.md 39 | - Anharmonic free energy: program/anharmonic_free_energy.md 40 | - Atomic distribution: program/atomic_distribution.md 41 | - Pack simulation: program/pack_simulation.md 42 | - Samples from MD: program/samples_from_md.md 43 | - Dump dynamical matrices: program/dump_dynamical_matrices.md 44 | - Crystal structure info: program/crystal_structure_info.md 45 | - Refine structure: program/refine_structure.md 46 | - Phase space: program/phasespace_surface.md 47 | - Files: files.md 48 | 49 | markdown_extensions: 50 | - pymdownx.arithmatex: 51 | generic: true 52 | - footnotes 53 | - pymdownx.highlight: 54 | anchor_linenums: true 55 | line_spans: __span 56 | pygments_lang_class: true 57 | - pymdownx.inlinehilite 58 | - pymdownx.snippets 59 | - pymdownx.superfences 60 | - admonition 61 | - pymdownx.tabbed: 62 | alternate_style: true 63 | 64 | extra_javascript: 65 | - javascripts/mathjax.js 66 | - https://polyfill.io/v3/polyfill.min.js?features=es6 67 | - https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js 68 | -------------------------------------------------------------------------------- /src/crystal_structure_info/manual.md: -------------------------------------------------------------------------------- 1 | 2 | ## Long summary 3 | 4 | This is mainly a diagnostic tool, to make sure that my heuristics are working as they should. For example, if you want to calculate fcc Al, and things look strange, run this code to make sure that the symmetry detection actually identifies it as fcc. As a bonus, the Brillouin zone and the irreducible wedge is printed to file, so that you can make figures like the one below. 5 | 6 |
7 | 8 |
9 | 10 | ### Input files 11 | 12 | * [infile.ucposcar](../files.md#infile.ucposcar) 13 | 14 | ### Output files 15 | 16 | #### `outfile.brillouin_zone.hdf5` 17 | 18 | This contains the information to produce the plot above. I did it with the following matlab snippet: 19 | 20 | ```matlab 21 | % read all the stuff 22 | fn='outfile.brillouin_zone.hdf5'; 23 | zone_nodes=h5read(fn,'/zone_nodes')'; 24 | wedge_nodes=h5read(fn,'/wedge_nodes')'; 25 | nf=h5readatt(fn,'/','number_of_zone_faces'); 26 | for i=1:nf 27 | zone_faces{i}=h5read(fn,['/zone_face_' num2str(i)]); 28 | end 29 | nf=h5readatt(fn,'/','number_of_wedge_faces'); 30 | for i=1:nf 31 | wedge_faces{i}=h5read(fn,['/wedge_face_' num2str(i)]); 32 | end 33 | labels=strsplit(h5readatt(fn,'/','wedge_node_labels')); 34 | 35 | figure(1); clf; hold on; axis equal off; view(3); camlight; 36 | i=drawPolyhedron(zone_nodes,zone_faces); 37 | set(i,'facealpha',0.3) 38 | j=drawPolyhedron(wedge_nodes,wedge_faces); 39 | set(j,'facealpha',0.3,'facecolor','blue') 40 | for i=1:length(labels) 41 | text(wedge_nodes(i,1),wedge_nodes(i,2),wedge_nodes(i,3),labels{i}) 42 | end 43 | ``` 44 | 45 | This requires the [Geom3D](http://www.mathworks.com/matlabcentral/fileexchange/24484-geom3d) package. 46 | 47 | #### `outfile.qpoints_dispersion` 48 | 49 | This is a prototype version of [infile.qpoints_dispersion](../files.md#infile.qpoints_dispersion), so that you don't have to start from nothing when changin the path. It can look like this: 50 | 51 | ``` 52 | FCC ! Bravais lattice type 53 | 100 ! Number of points on each path 54 | 4 ! Number paths between special points 55 | GM X ! Starting and ending special point 56 | X U ! 57 | K GM ! 58 | GM L ! 59 | ``` 60 | -------------------------------------------------------------------------------- /examples/build/important_settings.apple_silicon_gfortran12: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # A central place to put all the important paths. You probably have to modify this to make things work. 3 | 4 | # the fortran compiler 5 | FORTRAN_COMPILER="gfortran-12" 6 | # required compiler flags 7 | FCFLAGS="-ffree-line-length-none -std=f2008 -cpp -fallow-argument-mismatch" 8 | # extra flags, for debugging and such 9 | FCFLAGS_EXTRA="" 10 | # FCFLAGS_EXTRA="-fbacktrace -fcheck=all -finit-real=nan -finit-derived -fmax-errors=10 --pedantic --warn-all" 11 | # FCFLAGS_EXTRA="-g -fbacktrace -fcheck=all -finit-real=nan -finit-derived -fmax-errors=10 --pedantic -Wall -Wextra -pedantic -Wcast-align -Wdisabled-optimization -Wmissing-include-dirs -Wshadow -Wunused -fdiagnostics-show-option -fcheck=all -Wstrict-overflow=0 -Wrealloc-lhs" 12 | 13 | # optimization stuff. Go all in, sometimes 14 | # OPTIMIZATION_LEVEL="-Ofast" 15 | OPTIMIZATION_LEVEL="-O3" 16 | OPTIMIZATION_SENSITIVE="-O0" 17 | 18 | # the flag that sets the default real to a double. 19 | DOUBLE_FLAG="-fdefault-real-8" 20 | # The flag that tells the compiler where to put .o and .mod files. 21 | MODULE_FLAG="-J" 22 | 23 | # the header to put in python scripts. 24 | PYTHONHEADER="#!/usr/bin/env python" 25 | 26 | # Which gnuplot terminal to use by default. 27 | # Choices: aqua, qt, wxt 28 | GNUPLOTTERMINAL="aqua" # nice on OSX, needs aquaterm installed and gnuplot compiled with support for it. 29 | 30 | # Precompiler flags. Selecting default gnuplot terminal, and make the progressbars work. 31 | PRECOMPILER_FLAGS="-DGP${GNUPLOTTERMINAL} -Dclusterprogressbar -DAGRESSIVE_SANITY" 32 | PRECOMPILER_FLAGS="-DGP${GNUPLOTTERMINAL} -Dclusterprogressbar" 33 | 34 | # These are the BLAS/LAPACK libraries. On OSX with gfortran, use the built-in 'framework accelerate' 35 | PATH_TO_BLASLAPACK_LIB="" 36 | PATH_TO_BLASLAPACK_INC="" 37 | BLASLAPACK_LIBS="-framework accelerate" 38 | 39 | # I use fftw for Fourier transforms. 40 | PATH_TO_FFTW_LIB="-L/opt/homebrew/lib" 41 | PATH_TO_FFTW_INC="-I/opt/homebrew/include" 42 | FFTW_LIBS="-lfftw3" 43 | 44 | # Also need MPI 45 | PATH_TO_MPI_LIB="-L/opt/homebrew/lib" 46 | PATH_TO_MPI_INC="-I/opt/homebrew/include" 47 | MPI_LIBS="-lmpi_mpifh -lmpi" 48 | 49 | # I also use HDF5 every now and then 50 | PATH_TO_HDF5_LIB="-L/path/to/your/local/hdf5-1.XX/build/lib" 51 | PATH_TO_HDF5_INC="-I/path/to/your/local/hdf5-1.XX/build/include" 52 | HDF5_LIBS="-lhdf5 -lhdf5_fortran" 53 | 54 | -------------------------------------------------------------------------------- /docs/program/README.md: -------------------------------------------------------------------------------- 1 | # Programs 2 | 3 | [`generate_structure`: Generate supercells of target size, with options to make them as cubic as possible to maximize the real-space cutoff for the force constants.](generate_structure.md) 4 | 5 | [`canonical_configuration`: Create supercells with thermal displacements from an initial guess or existing force constants, using Monte Carlo sampling from a classical or quantum canonical distribution.](canonical_configuration.md) 6 | 7 | [`extract_forceconstants`: Obtain (effective) harmonic force constants from a set of supercell snapshots with displaced positions and forces. Optionally fit higher-order force constants.](extract_forceconstants.md) 8 | 9 | [`phonon_dispersion_relations`: Calculate phonon dispersion relations and related harmonic thermodynamic properties from the second-order force constants.](phonon_dispersion_relations.md) 10 | 11 | [`thermal_conductivity`: Compute thermal transport by solving the phonon Boltzmann transport equation with perturbative treatment of third-order anharmonicity.](thermal_conductivity.md) 12 | 13 | [`lineshape`: Compute phonon spectral functions including lifetime broadening and shifts for single q-points, q-point meshes, or q-point paths in the Brillouin zone. The grid mode computes _spectral_ thermal transport properties as well.](lineshape.md) 14 | 15 | [`anharmonic_free_energy`: Compute the free energy including anharmonic contributions.](anharmonic_free_energy.md) 16 | 17 | [`atomic_distribution`: Compute pair distribution functions.](atomic_distribution.md) 18 | 19 | [`pack_simulation`: Clean, compress and store simulation data.](pack_simulation.md) 20 | 21 | [`samples_from_md`: Pick samples from an MD simulation in a clever way.](samples_from_md.md) 22 | 23 | [`dump_dynamical_matrices`: Write dynamical matrices on q-point grid.](dump_dynamical_matrices.md) 24 | 25 | [`crystal_structure_info`: Report which crystal structure and spacegroup TDEP sees.](crystal_structure_info.md) 26 | 27 | [`refine_structure`: Clean up input structures with imprecise symmetry.](refine_structure.md) 28 | 29 | [`phasespace_surface`: Compute the phonon scattering phase space.](phasespace_surface.md) 30 | 31 | [`thermal_conductivity_2023`: Compute thermal transport by solving the phonon Boltzmann transport equation with perturbative treatment of third-order anharmonicity. Older implementation, the new program should be used.](thermal_conductivity_2023.md) 32 | -------------------------------------------------------------------------------- /examples/build/important_settings.conda: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # A central place to put all the important paths. You probably have to modify this to make things work. 3 | 4 | # prefix of your conda environment folder (in which you have ./bin, ./lib, ./include, ... directories) 5 | PREFIX=/path/to/your/conda/environment 6 | 7 | # the fortran compiler 8 | FORTRAN_COMPILER="$PREFIX/bin/mpifort" 9 | # required compiler flags 10 | FCFLAGS="-ffree-line-length-none -std=f2008 -cpp -fallow-argument-mismatch" 11 | # extra flags, for debugging and such 12 | FCFLAGS_EXTRA="" 13 | # FCFLAGS_EXTRA="-fbacktrace -fcheck=all -finit-real=nan -finit-derived -fmax-errors=10 --pedantic --warn-all" 14 | # FCFLAGS_EXTRA="-g -fbacktrace -fcheck=all -finit-real=nan -finit-derived -fmax-errors=10 --pedantic -Wall -Wextra -pedantic -Wcast-align -Wdisabled-optimization -Wmissing-include-dirs -Wshadow -Wunused -fdiagnostics-show-option -fcheck=all -Wstrict-overflow=0 -Wrealloc-lhs" 15 | 16 | # optimization stuff. Go all in, sometimes 17 | # OPTIMIZATION_LEVEL="-Ofast" 18 | OPTIMIZATION_LEVEL="-O0" 19 | OPTIMIZATION_SENSITIVE="-O0" 20 | 21 | # the flag that sets the default real to a double. 22 | DOUBLE_FLAG= # "-fdefault-real-8" 23 | # The flag that tells the compiler where to put .o and .mod files. 24 | MODULE_FLAG="-J" 25 | 26 | # the header to put in python scripts. 27 | PYTHONHEADER="#!/usr/bin/env python" 28 | 29 | # Which gnuplot terminal to use by default. 30 | # Choices: aqua, qt, wxt 31 | GNUPLOTTERMINAL="qt" 32 | 33 | # Precompiler flags. Selecting default gnuplot terminal, and make the progressbars work. 34 | PRECOMPILER_FLAGS="-DGP${GNUPLOTTERMINAL} -Dclusterprogressbar -DAGRESSIVE_SANITY" 35 | PRECOMPILER_FLAGS="-DGP${GNUPLOTTERMINAL} -Dclusterprogressbar" 36 | 37 | # These are the BLAS/LAPACK libraries. On OSX with gfortran, use the built-in 'framework accelerate' 38 | PATH_TO_BLASLAPACK_LIB="-L/$PREFIX/lib" 39 | PATH_TO_BLASLAPACK_INC="-I/$PREFIX/include" 40 | BLASLAPACK_LIBS="-llapack -lscalapack" 41 | 42 | # I use fftw for Fourier transforms. 43 | PATH_TO_FFTW_LIB="-L/$PREFIX/lib" 44 | PATH_TO_FFTW_INC="-I/$PREFIX/include" 45 | FFTW_LIBS="-lfftw3" 46 | 47 | # Also need MPI 48 | PATH_TO_MPI_LIB="-L/$PREFIX/lib" 49 | PATH_TO_MPI_INC="-I/$PREFIX/include" 50 | MPI_LIBS="-lmpi_mpifh -lmpi" 51 | 52 | # I also use HDF5 every now and then 53 | PATH_TO_HDF5_LIB="-L/$PREFIX/lib" 54 | PATH_TO_HDF5_INC="-I/$PREFIX/include" 55 | HDF5_LIBS="-lhdf5 -lhdf5_fortran" 56 | 57 | -------------------------------------------------------------------------------- /src/phonon_dispersion_relations/Makefile: -------------------------------------------------------------------------------- 1 | # I made this so I have this line under control. 2 | include Makefile.inc 3 | # ok, I understand this one. 4 | CODE = phonon_dispersion_relations 5 | # this one as well 6 | PROG = ../../build/$(CODE)/$(CODE) 7 | OBJECT_PATH=../../build/$(CODE)/ 8 | 9 | # list of stuff. Used for something at least. 10 | OBJS = \ 11 | $(OBJECT_PATH)main.o\ 12 | $(OBJECT_PATH)options.o\ 13 | $(OBJECT_PATH)densityplots.o\ 14 | $(OBJECT_PATH)densityplots_stuntscattering.o\ 15 | $(OBJECT_PATH)unfold_phonons.o\ 16 | $(OBJECT_PATH)type_fast_interpolation.o\ 17 | $(OBJECT_PATH)velocitydos.o\ 18 | $(OBJECT_PATH)activity.o 19 | 20 | # some paths and stuff. Ok. 21 | LPATH = -L../../lib $(blaslapackLPATH) $(incLPATHhdf) $(incLPATHmpi) $(incLPATHfft) 22 | IPATH = -I../../inc/libolle -I../../inc/libflap $(blaslapackIPATH) $(incIPATHhdf) $(incIPATHmpi) $(incIPATHfft) 23 | LIBS = ../../lib/libolle.a -lflap $(blaslapackLIBS) $(incLIBShdf) $(incLIBSmpi) $(incLIBSfft) 24 | 25 | # ok, I think I get this. 26 | #OPT = -O0 -fbacktrace -fcheck=all -finit-real=nan -finit-derived -fmax-errors=10 27 | F90 = $(FC) $(LPATH) $(IPATH) $(MODULE_FLAG) $(OBJECT_PATH) #$(warnings_gcc) 28 | F90FLAGS = $(OPT) $(MODS) $(LIBS) 29 | 30 | # I guess this is the normal one 31 | all: $(PROG) 32 | 33 | $(PROG): $(OBJS) 34 | $(F90) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) 35 | 36 | # ok, I understand this 37 | clean: 38 | rm -f $(PROG) $(OBJS) *.mod 39 | 40 | # This I understand, but it seems stupid. 41 | $(OBJECT_PATH)main.o:\ 42 | $(OBJECT_PATH)options.o\ 43 | $(OBJECT_PATH)densityplots.o\ 44 | $(OBJECT_PATH)unfold_phonons.o\ 45 | $(OBJECT_PATH)type_fast_interpolation.o\ 46 | $(OBJECT_PATH)velocitydos.o\ 47 | $(OBJECT_PATH)activity.o 48 | $(F90) $(F90FLAGS) -c main.f90 $(LIBS) -o $@ 49 | $(OBJECT_PATH)densityplots.o: $(OBJECT_PATH)options.o 50 | $(F90) $(F90FLAGS) -c densityplots.f90 $(LIBS) -o $@ 51 | $(OBJECT_PATH)densityplots_stuntscattering.o: $(OBJECT_PATH)densityplots.o 52 | $(F90) $(F90FLAGS) -c densityplots_stuntscattering.f90 $(LIBS) -o $@ 53 | $(OBJECT_PATH)velocitydos.o: 54 | $(F90) $(F90FLAGS) -c velocitydos.f90 $(LIBS) -o $@ 55 | $(OBJECT_PATH)unfold_phonons.o: $(OBJECT_PATH)type_fast_interpolation.o 56 | $(F90) $(F90FLAGS) -c unfold_phonons.f90 $(LIBS) -o $@ 57 | $(OBJECT_PATH)type_fast_interpolation.o: 58 | $(F90) $(F90FLAGS) -c type_fast_interpolation.f90 $(LIBS) -o $@ 59 | $(OBJECT_PATH)activity.o: 60 | $(F90) $(F90FLAGS) -c activity.f90 $(LIBS) -o $@ 61 | $(OBJECT_PATH)options.o: 62 | $(F90) $(F90FLAGS) -c options.f90 $(LIBS) -o $@ 63 | -------------------------------------------------------------------------------- /src/samples_from_md/options.f90: -------------------------------------------------------------------------------- 1 | #include "precompilerdefinitions" 2 | module options 3 | use konstanter, only: flyt, lo_author, lo_licence, lo_version, lo_status 4 | use flap, only: command_line_interface 5 | implicit none 6 | private 7 | public :: lo_opts 8 | 9 | type lo_opts 10 | integer :: n 11 | integer :: maxiter 12 | real(flyt) :: temp 13 | integer :: output_format 14 | contains 15 | procedure :: parse 16 | end type 17 | 18 | contains 19 | 20 | !> parse the command line arguments and set defaults 21 | subroutine parse(opts) 22 | !> the options 23 | class(lo_opts), intent(out) :: opts 24 | !> the helper parser 25 | type(command_line_interface) :: cli 26 | 27 | logical :: dumlog 28 | 29 | call cli%init(progname='samples_from_md', & 30 | authors=lo_author, & 31 | version=lo_version, & 32 | license=lo_licence, & 33 | help='Usage: ', & 34 | description='Choose representative uncorrelated samples from an MD simulation. The samples are chosen to be approximately evenly spaced, and reproduce the average potential energy, average kinetic energy have the same standard deviation of potential and kinetic energy.', & 35 | examples=["samples_from_md -n 100"], & 36 | epilog=new_line('a')//"...") 37 | 38 | call cli%add(switch='--nsamples', switch_ab='-n', & 39 | help='Number of samples', & 40 | required=.false., act='store', def='50', error=lo_status) 41 | if (lo_status .ne. 0) stop 42 | call cli%add(switch='--output_format', switch_ab='-of', & 43 | help='Selects output format. 1 is VASP, 2 is Abinit, 4 is FHI-Aims, 5 is Siesta. Default 1.', & 44 | required=.false., act='store', def='1', choices='1,2,4,5', error=lo_status) 45 | if (lo_status .ne. 0) stop 46 | 47 | cli_manpage 48 | dumlog = .false. 49 | call cli%get(switch='--manpage', val=dumlog) 50 | if (dumlog) then 51 | call cli%save_man_page(trim(cli%progname)//'.1') 52 | call cli%save_usage_to_markdown(trim(cli%progname)//'.md') 53 | write (*, *) 'Wrote manpage for "'//trim(cli%progname)//'"' 54 | stop 55 | end if 56 | ! actually parse it 57 | call cli%parse(error=lo_status) 58 | if (lo_status .ne. 0) stop 59 | call cli%get(switch='--nsamples', val=opts%n) 60 | call cli%get(switch='--output_format', val=opts%output_format) 61 | opts%maxiter = 100000 62 | opts%temp = 1E-4_flyt 63 | end subroutine 64 | 65 | end module 66 | -------------------------------------------------------------------------------- /docs/program/samples_from_md.md: -------------------------------------------------------------------------------- 1 | 2 | ### Short description 3 | 4 | Choose representative uncorrelated samples from an MD simulation. The samples are chosen to be approximately evenly spaced, and reproduce the average potential energy, average kinetic energy have the same standard deviation of potential and kinetic energy. 5 | 6 | ### Command line options: 7 | 8 | 9 | 10 | 11 | Optional switches: 12 | 13 | * `--nsamples value`, `-n value` 14 | default value 50 15 | Number of samples 16 | 17 | * `--output_format value`, `-of value`, value in: `1,2,4,5` 18 | default value 1 19 | Output format. 1 is VASP, 2 Abinit, 4 FHI-AIMS, 5 Siesta 20 | 21 | * `--help`, `-h` 22 | Print this help message 23 | 24 | * `--version`, `-v` 25 | Print version 26 | ### Examples 27 | 28 | `samples_from_md -n 100` 29 | 30 | ### Longer summary 31 | 32 | Ab initio molecular dynamics are expensive calculations. There will be a tradeoff between numerical precision and the number of timesteps. To work around this, you can run the MD with rather low precision and gather statistics. Then, from the long simulation, choose a set of uncorrelated configurations and recalculate these with high precision. 33 | 34 | From these low accuracy calculations we choose a set of $n$ uncorrelated samples and correct scalar parameter $a$ as 35 | 36 | $$ 37 | \begin{equation} 38 | a = + \frac{1}{n}\sum_{i=1}^n a^h_i-a_i^l, 39 | \end{equation} 40 | $$ 41 | 42 | where $a^l$ are the low accuracy calculations and $a^h$ are calculations done with high accuracy. This exploits the fact that most omissions of numerical accuracy, such as basis set and k-point selection, lead to additive errors. This technique is well suited to determine the interatomic force constants and resulting thermodynamic/transport properties with high accuracy. 43 | 44 | This code selects a choice of uncorrelated samples from BOMD via a Monte-Carlo algorithm, assuring the selection is not biased. We start with a calculation of average potential $E_p$, kinetic energies $E_k$, and their standard deviation. We check the distance between samples assuring that chosen samples are not temporally adjacent. The results of this procedure is written in output files (`outfile.stat_sample`). The average values and distance between selected points depend on the number of desired samples. 45 | 46 | ### Input files 47 | 48 | * [infile.ucposcar](../files.md#infile.ucposcar) 49 | * [infile.ssposcar](../files.md#infile.ssposcar) 50 | * [infile.meta](../files.md#infile.meta) 51 | * [infile.stat](../files.md#infile.stat) 52 | * [infile.positions](../files.md#infile.positions) 53 | * [infile.forces](../files.md#infile.forces) 54 | 55 | ### Output files 56 | 57 | This code will generate a series of structures in the specified output format. 58 | 59 | 60 | -------------------------------------------------------------------------------- /examples/build/important_settings.tetralith.cgal: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # A central place to put all the important paths. You probably have to modify this to make 4 | # things work. 5 | 6 | # Sigma/Tetralith 2024: 7 | module load buildenv-intel/2023a-eb 8 | module load HDF5/1.12.2-hpc1 9 | 10 | # the header to put in python scripts. 11 | PYTHONHEADER="#!/bin/env python" 12 | 13 | # Which gnuplot terminal to use by default. 14 | GNUPLOTTERMINAL="wxt" # other options are "aqua" and "x11" 15 | 16 | # the fortran compiler 17 | FORTRAN_COMPILER="mpiifort" 18 | OPTIMIZATION_LEVEL="-O3 -xCORE-AVX512" # first time you try you might want to put this to -O0 to make things compile a little faster. 19 | #OPTIMIZATION_LEVEL="-O0 -check bounds -check uninit -check pointers -check stack -traceback -g -fpe0 -init=snan,arrays -warn all -warn stderrors -stand f08 -diag-disable 5268" 20 | 21 | # Extra options for the compiler to make it play nice 22 | FCFLAGS="-ip -fpp -fp-model precise -qmkl=cluster" 23 | 24 | # flag that specifies location of modules 25 | MODULE_FLAG="-module" 26 | 27 | # Precompiler flags. Selecting default gnuplot terminal, and makes the progressbars work. 28 | PRECOMPILER_FLAGS="-DGP${GNUPLOTTERMINAL} -Dclusterprogressbar" 29 | 30 | # you need BLAS and LAPACK 31 | PATH_TO_BLASLAPACK_LIB="" # "-L${MKLROOT}/lib/intel64" 32 | PATH_TO_BLASLAPACK_INC="" # "-I${MKLROOT}/include" 33 | BLASLAPACK_LIBS="" # "-lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lmkl_blacs_intelmpi_lp64 -lmkl_scalapack_lp64" 34 | 35 | # I need the fftw library 36 | PATH_TO_FFTW_LIB="" 37 | PATH_TO_FFTW_INC="" # -I${MKL_ROOT}/include/fftw" 38 | FFTW_LIBS="" 39 | 40 | # Also need MPI 41 | PATH_TO_MPI_LIB="" # "-L${I_MPI_ROOT}/intel64/lib" 42 | PATH_TO_MPI_INC="" # "-I${I_MPI_ROOT}/intel64/include" 43 | MPI_LIBS="" # "-lmpi -lmpifort" 44 | 45 | # And a c-compiler 46 | C_COMPILER="icc" 47 | 48 | # And HDF5 49 | PATH_TO_HDF5_LIB="-L${HDF5_DIR}/lib" 50 | PATH_TO_HDF5_INC="-I${HDF5_DIR}/include" 51 | HDF5_LIBS="-lhdf5 -lhdf5_fortran" 52 | 53 | # Optionally CGAL and FHI-Aims. You probably do not want that. 54 | USEAIMS="no" 55 | 56 | # Let's do it 57 | USECGAL="yes" 58 | 59 | # need some more modules 60 | module load GCCcore/11.3.0 61 | module load POV-Ray/3.7.0.10-hpc1-gcc-2022a-eb 62 | module load Boost/1.79.0 63 | module load GMP/6.2.1 64 | module load MPFR/4.1.0 65 | module load Eigen/3.4.0 66 | 67 | CGAL_PATH="/proj/theophys/users/x_flokn/local/CGAL/cgal-5.6.1/build" 68 | 69 | # CGAL is written in c++. I have wrapper functions in C, that I call from Fortran. 70 | CPP_COMPILER="gcc" 71 | CPP_FLAGS="--std=c++14 -frounding-math -O3 -Dusecgal -DCGAL_USE_GMP -DCGAL_USE_MPFR -DCGAL_EIGEN3_ENABLED -DNDEBUG -DBOOST_PARAMETER_MAX_ARITY=12 -Wno-deprecated-declarations" 72 | CGALLINKLINE="-lstdc++ -lmpfr -lgmp -lboost_system" 73 | 74 | PATH_TO_CGAL_LIB="-L$CGAL_PATH/lib64" 75 | PATH_TO_CGAL_INC="-I$CGAL_PATH/include/" 76 | 77 | 78 | -------------------------------------------------------------------------------- /src/crystal_structure_info/options.f90: -------------------------------------------------------------------------------- 1 | #include "precompilerdefinitions" 2 | module options 3 | use konstanter, only: lo_author, lo_version, lo_licence, lo_status 4 | use flap, only: command_line_interface 5 | implicit none 6 | private 7 | public :: lo_opts 8 | 9 | type lo_opts 10 | !> Print out the symmetry operations 11 | logical :: printsymmetry 12 | !> How much to talk 13 | integer :: verbosity 14 | !> Consider time reversal symmetry 15 | logical :: timereversal 16 | contains 17 | procedure :: parse 18 | end type 19 | 20 | contains 21 | 22 | !> parse the command line arguments and set defaults 23 | subroutine parse(opts) 24 | !> the options 25 | class(lo_opts), intent(out) :: opts 26 | !> the helper parser 27 | type(command_line_interface) :: cli 28 | ! 29 | logical :: dumlog 30 | ! 31 | call cli%init(progname='crystal_structure_info', & 32 | authors=lo_author, & 33 | version=lo_version, & 34 | license=lo_licence, & 35 | help='Usage: ', & 36 | description='This code serves as a diagnostic tool to check that symmetry heuristics are working as they should. The code prints which Bravais lattice was identified, which high symmetry points in the BZ are inequivalent, and so on. The Brillouin zone and its irreducible wedges are printed to files as polyhedra for manual inspection, and the symmetry operations of the lattice can be printed.', & 37 | examples=["crystal_structure_info ", & 38 | "crystal_structure_info --printsymmetry"], & 39 | epilog=new_line('a')//"...") 40 | ! 41 | call cli%add(switch='--printsymmetry', & 42 | help='Also prints the symmetry operations', & 43 | required=.false., act='store_true', def='.false.', error=lo_status) 44 | if (lo_status .ne. 0) stop 45 | call cli%add(switch='--notr', hidden=.true., help='', & 46 | required=.false., act='store_true', def='.false.', error=lo_status) 47 | if (lo_status .ne. 0) stop 48 | 49 | ! 50 | cli_manpage 51 | cli_verbose 52 | ! actually parse it 53 | call cli%parse(error=lo_status) 54 | if (lo_status .ne. 0) stop 55 | ! generate manpage? 56 | call cli%get(switch='--manpage', val=dumlog) 57 | if (dumlog) then 58 | call cli%save_man_page(trim(cli%progname)//'.1') 59 | call cli%save_usage_to_markdown(trim(cli%progname)//'.md') 60 | write (*, *) 'Wrote manpage for "'//trim(cli%progname)//'"' 61 | stop 62 | end if 63 | ! verbosity? 64 | opts%verbosity = 0 65 | call cli%get(switch='--verbose', val=dumlog) 66 | if (dumlog) opts%verbosity = 2 67 | call cli%get(switch='--printsymmetry', val=opts%printsymmetry) 68 | call cli%get(switch='--notr', val=dumlog) 69 | opts%timereversal = .not. dumlog 70 | ! 71 | end subroutine 72 | 73 | end module 74 | -------------------------------------------------------------------------------- /.github/workflows/ci_simple_compilation_and_test.yml: -------------------------------------------------------------------------------- 1 | name: Compile TDEP and test binaries 2 | run-name: ${{ github.actor }} is trying to compile and run TDEP 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | paths: 9 | - .github/workflows/ci_simple_compilation_and_test.yml 10 | - src/** 11 | - tests/** 12 | workflow_dispatch: 13 | 14 | env: 15 | ARTIFACTS: tdep-test-artifacts 16 | N_THREADS: 4 17 | 18 | jobs: 19 | Compile-and-run-TDEP: 20 | runs-on: ${{ vars.RUNNER || 'ubuntu-latest' }} 21 | timeout-minutes: 20 22 | steps: 23 | - name: Check out TDEP code 24 | uses: actions/checkout@v4 25 | with: 26 | repository: tdep-developers/tdep 27 | - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." 28 | - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." 29 | - name: Install packages required for building TDEP 30 | run: | 31 | sudo apt-get update 32 | sudo apt-get install -y \ 33 | gfortran \ 34 | libblas-dev \ 35 | liblapack-dev \ 36 | libhdf5-dev \ 37 | libhdf5-serial-dev \ 38 | libhdf5-openmpi-dev \ 39 | openmpi-bin \ 40 | libopenmpi-dev \ 41 | libfftw3-dev \ 42 | libscalapack-openmpi-dev 43 | - name: compile TDEP with debug flags 44 | id: compile_debug 45 | run: | 46 | cd ${{ github.workspace }} 47 | cp .github/important_settings.x86_64 important_settings 48 | cat .github/important_settings.fastcompile >> important_settings 49 | cat .github/important_settings.x86_64_debugflags >> important_settings 50 | bash build_things.sh --nthreads_make ${{ env.N_THREADS }} 51 | - name: compile TDEP production 52 | if: steps.compile_debug.outcome == 'success' 53 | id: compile_production 54 | run: | 55 | cd ${{ github.workspace }} 56 | cp .github/important_settings.x86_64 important_settings 57 | bash build_things.sh --nthreads_make ${{ env.N_THREADS }} 58 | - name: Create testfiles 59 | id: testfiles 60 | if: steps.compile_production.outcome == 'success' 61 | run: | 62 | cd ${{ github.workspace }}/tests 63 | make 64 | - name: Check tests 65 | id: test 66 | if: steps.testfiles.outcome == 'success' 67 | run: | 68 | cd ${{ github.workspace }}/tests 69 | pip install -r requirements.txt 70 | make test || exit 1 71 | - name: Upload results 72 | uses: actions/upload-artifact@v4 73 | if: failure() 74 | with: 75 | name: ${{ env.ARTIFACTS }} 76 | path: | 77 | ${{ github.workspace }}/bin/ 78 | ${{ github.workspace }}/build/ 79 | ${{ github.workspace }}/tests/ 80 | ${{ github.workspace }}/bashrc_tdep 81 | retention-days: 7 82 | -------------------------------------------------------------------------------- /docs/program/crystal_structure_info.md: -------------------------------------------------------------------------------- 1 | 2 | ### Short description 3 | 4 | This code serves as a diagnostic tool to check that symmetry heuristics are working as they should. The code prints which Bravais lattice was identified, which high symmetry points in the BZ are inequivalent, and so on. The Brillouin zone and its irreducible wedges are printed to files as polyhedra for manual inspection, and the symmetry operations of the lattice can be printed. 5 | 6 | ### Command line options: 7 | 8 | 9 | 10 | 11 | Optional switches: 12 | 13 | * `--printsymmetry` 14 | default value .false. 15 | Also prints the symmetry operations 16 | 17 | * `--help`, `-h` 18 | Print this help message 19 | 20 | * `--version`, `-v` 21 | Print version 22 | ### Examples 23 | 24 | `crystal_structure_info` 25 | 26 | `crystal_structure_info --printsymmetry` 27 | 28 | ## Long summary 29 | 30 | This is mainly a diagnostic tool, to make sure that my heuristics are working as they should. For example, if you want to calculate fcc Al, and things look strange, run this code to make sure that the symmetry detection actually identifies it as fcc. As a bonus, the Brillouin zone and the irreducible wedge is printed to file, so that you can make figures like the one below. 31 | 32 |
33 | 34 |
35 | 36 | ### Input files 37 | 38 | * [infile.ucposcar](../files.md#infile.ucposcar) 39 | 40 | ### Output files 41 | 42 | #### `outfile.brillouin_zone.hdf5` 43 | 44 | This contains the information to produce the plot above. I did it with the following matlab snippet: 45 | 46 | ```matlab 47 | % read all the stuff 48 | fn='outfile.brillouin_zone.hdf5'; 49 | zone_nodes=h5read(fn,'/zone_nodes')'; 50 | wedge_nodes=h5read(fn,'/wedge_nodes')'; 51 | nf=h5readatt(fn,'/','number_of_zone_faces'); 52 | for i=1:nf 53 | zone_faces{i}=h5read(fn,['/zone_face_' num2str(i)]); 54 | end 55 | nf=h5readatt(fn,'/','number_of_wedge_faces'); 56 | for i=1:nf 57 | wedge_faces{i}=h5read(fn,['/wedge_face_' num2str(i)]); 58 | end 59 | labels=strsplit(h5readatt(fn,'/','wedge_node_labels')); 60 | 61 | figure(1); clf; hold on; axis equal off; view(3); camlight; 62 | i=drawPolyhedron(zone_nodes,zone_faces); 63 | set(i,'facealpha',0.3) 64 | j=drawPolyhedron(wedge_nodes,wedge_faces); 65 | set(j,'facealpha',0.3,'facecolor','blue') 66 | for i=1:length(labels) 67 | text(wedge_nodes(i,1),wedge_nodes(i,2),wedge_nodes(i,3),labels{i}) 68 | end 69 | ``` 70 | 71 | This requires the [Geom3D](http://www.mathworks.com/matlabcentral/fileexchange/24484-geom3d) package. 72 | 73 | #### `outfile.qpoints_dispersion` 74 | 75 | This is a prototype version of [infile.qpoints_dispersion](../files.md#infile.qpoints_dispersion), so that you don't have to start from nothing when changin the path. It can look like this: 76 | 77 | ``` 78 | FCC ! Bravais lattice type 79 | 100 ! Number of points on each path 80 | 4 ! Number paths between special points 81 | GM X ! Starting and ending special point 82 | X U ! 83 | K GM ! 84 | GM L ! 85 | ``` 86 | -------------------------------------------------------------------------------- /src/thermal_conductivity/scattering_isotope.f90: -------------------------------------------------------------------------------- 1 | 2 | subroutine compute_isotope_scattering(il, sr, qp, dr, uc, temperature, & 3 | g0, integrationtype, smearing, mw, mem) 4 | !> The local point 5 | integer, intent(in) :: il 6 | !> The scattering amplitudes 7 | type(lo_scattering_rates), intent(inout) :: sr 8 | !> The q-point mesh 9 | class(lo_qpoint_mesh), intent(in) :: qp 10 | !> phonon dispersions 11 | type(lo_phonon_dispersions), intent(inout) :: dr 12 | !> structure 13 | type(lo_crystalstructure), intent(in) :: uc 14 | !> The temperature 15 | real(r8), intent(in) :: temperature 16 | !> The linewidth for this mode 17 | real(r8), intent(inout) :: g0 18 | !> what kind of integration are we doing 19 | integer, intent(in) :: integrationtype 20 | !> The smearing width 21 | real(r8), intent(in) :: smearing 22 | !> MPI helper 23 | type(lo_mpi_helper), intent(inout) :: mw 24 | !> memory tracker 25 | type(lo_mem_helper), intent(inout) :: mem 26 | 27 | ! Eigenvectors 28 | complex(r8), dimension(uc%na*3, 2) :: egviso 29 | ! prefactor and phonon buffers 30 | real(r8) :: om1, om2, sigma, psisq, prefactor, f0 31 | ! Integers for do loops 32 | integer :: q1, b1, q2, b2, i, niso 33 | 34 | q1 = sr%my_qpoints(il) 35 | b1 = sr%my_modes(il) 36 | om1 = dr%iq(q1)%omega(b1) 37 | egviso(:, 1) = dr%iq(q1)%egv(:, b1) 38 | 39 | do q2 = 1, qp%n_full_point 40 | prefactor = isotope_prefactor*qp%ap(q2)%integration_weight 41 | do b2 = 1, dr%n_mode 42 | om2 = dr%aq(q2)%omega(b2) 43 | if (om2 .lt. lo_freqtol) cycle 44 | 45 | select case (integrationtype) 46 | case (1) 47 | sigma = lo_frequency_THz_to_Hartree*smearing 48 | case (2) 49 | sigma = sqrt(sr%sigsq(q1, b1) + & 50 | sr%sigsq(qp%ap(q2)%irreducible_index, b2)) 51 | case (6) 52 | sigma = qp%smearingparameter(dr%aq(q2)%vel(:, b2), & 53 | dr%default_smearing(b2), smearing) 54 | end select 55 | 56 | i = (q2 - 1)*dr%n_mode + b2 57 | 58 | egviso(:, 2) = dr%aq(q2)%egv(:, b2) 59 | 60 | psisq = isotope_scattering_strength(uc, egviso)*prefactor 61 | 62 | f0 = psisq*om1*om2*lo_gauss(om1, om2, sigma) 63 | g0 = g0 + f0 64 | sr%Xi(il, i) = sr%Xi(il, i) + f0*om2/om1 65 | end do 66 | end do 67 | end subroutine 68 | 69 | real(r8) function isotope_scattering_strength(uc, egv) 70 | type(lo_crystalstructure), intent(in) :: uc 71 | complex(r8), dimension(:, :), intent(in) :: egv 72 | ! 73 | integer :: i, j 74 | real(r8) :: f0, f1 75 | complex(r8), dimension(3) :: cv0, cv1 76 | 77 | f1 = 0.0_r8 78 | do i = 1, uc%na 79 | cv0 = egv((i - 1)*3 + 1:(i*3), 1) 80 | cv1 = egv((i - 1)*3 + 1:(i*3), 2) 81 | f0 = 0.0_r8 82 | do j = 1, 3 83 | f0 = f0 + abs(conjg(cv0(j))*cv1(j)) 84 | end do 85 | f0 = f0**2 86 | f1 = f1 + f0*uc%isotope(i)%disorderparameter 87 | end do 88 | isotope_scattering_strength = f1 89 | end function 90 | -------------------------------------------------------------------------------- /src/manual/workflows/minimal_example_6.md: -------------------------------------------------------------------------------- 1 | title: Minimal example VI 2 | author: Olle Hellman 3 | 4 | In the previous sections we dealt with calculations at a single temperature. Sometimes you want properties as a function of temperature. In `some folder` I prepared some input for ScF3 @note Or something else. 5 | 6 | #### Phonons dispersions as a function of temperature 7 | 8 | Make them plot in all three folders. 9 | 10 | Point out that you should only run extractforceconstants once. 11 | 12 | Plot all three. 13 | 14 | #### Interpolate 15 | 16 | For some reason you realise that you where not interested in the phonon dispersions at x,y,or z K, for reasons unknown you want to determine the dispersions at XX K instead. The naive way would be to do a new calculation at that temperature, but that takes a lot of time. It's better to interpolate. 17 | 18 | Interpolating the frequencies themselves could be done, but it's not great. Empirically, I have found out that if you interpolate the forceconstants instead, you will have better luck. 19 | 20 | This is a little involved, so we will break it into steps. 21 | 22 | Provided you followed the instructions and have run extract forceconstants in all three directories, you might have noted that there are files called `outfile.phi_secondorder`. As [described](../../program/extract_forceconstants.html), these are a list of the irreducible forceconstants. Copy this to an infile 23 | 24 | ``` 25 | cp outfile.phi_secondorder infile.phi_secondorder 26 | ``` 27 | And run 28 | 29 | ``` 30 | ./extract_forceconstants -r 31 | ``` 32 | Note that this runs much faster: by invoking the `-r` flag, it will read the values from file. Now, edit `infile.phi_secondorder` and change some random value to 100, run 33 | 34 | ``` 35 | ./extract_forceconstants -r 36 | phonon_dispersion_relations 37 | gnuplot outfile.dispersion_relations.gnuplot 38 | ``` 39 | The dispersions will probably look really strange. The point of this exercise was to understand how to modify an irreducible component and get a new `outfile.forceconstant` out. 40 | 41 | Since we know how to translate irreducible components to forceconstants, all we need to to is interpolate each irreducible component separately, translate to forceconstants, and calculate dispersions. This way you can get the dispersions at any temperature in the interval. 42 | 43 | I like to use matlab for this step, but it should be just as easy in python or some other scripting language. I will not go into details, since I assume you know how to interpolate things. You should construct a script that 44 | 45 | 1. Reads all N `outfile.phi_secondorder` 46 | 2. For each of the values in `outfile.phi_secondorder`, create an interpolation that can evaluate that value at any temperature. A second order polynomial works great. 47 | 3. At a temperature of interest, print a new `infile.phi_secondorder` with the interpolated values and run `extract_forceconstants -r`. This gives you a forceconstant at this temperature. 48 | 4. Run `phonon_dispersion_relations` with the new forceconstant, and store `outfile.dispersion_relations` somewhere. 49 | 5. Repeat this for say 50 temperatures in the valid range. Plot the results somehow. 50 | 51 | If successful, it should look something like this: 52 | 53 | @todo Some picture 54 | 55 | Or alternatively, just tracking the TO mode at gamma: 56 | 57 | @todo Some other picture. 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/manual/1_utilities.md: -------------------------------------------------------------------------------- 1 | title: Utility scripts 2 | 3 | Part of the package is a set of small tools that help with preparing input for post-processing. What they do is to parse output files and prepare intput files according to this [format](files.html). If you understand the format (and it is not particularly complicated), it is easy to generate a parsing script for any code. The minimal requirements are positions, forces and energies. Other quantities are there mostly for reference, and can safely be set to zero. 4 | 5 | #### VASP 6 | 7 | The scripts `process_outcar.py` and `process_outcar_5.3.py` are used to extract information from [VASP](https://www.vasp.at) OUTCAR files. The usage is straightforward: 8 | 9 | ``` 10 | process_outcar_5.3.py OUTCAR 11 | ``` 12 | 13 | This will create the relevant [input files](files.hmtl). Alternatively, is you used some statistical sampling method and have many VASP simulations that need to be stitched together, use 14 | 15 | ``` 16 | process_outcar_5.3.py *OUTCAR 17 | ``` 18 | 19 | That is, the script takes any number of OUTCARs as argument. The script assumes you have used `ISIF = 2`, since without it forces don't get written. 20 | 21 | #### Abinit 22 | 23 | @todo Get Antoine to send me his script. 24 | 25 | #### LAMMPS 26 | 27 | LAMMPS does not write anything by default. To get usable output, I make sure to add the following to the input file: 28 | 29 | ``` 30 | units metal 31 | 32 | variable st equal step 33 | variable tm equal step 34 | variable Et equal etotal 35 | variable Ep equal pe 36 | variable Ek equal ke 37 | variable tmp equal temp 38 | variable pr equal press/10000 39 | variable sxx equal pxx/10000 40 | variable syy equal pyy/10000 41 | variable szz equal pzz/10000 42 | variable sxy equal pxy/10000 43 | variable sxz equal pxz/10000 44 | variable syz equal pyz/10000 45 | 46 | fix statdump all print 100 "${st} ${tm} ${Et} ${Ep} ${Ek} ${tmp} ${pr} ${sxx} ${syy} ${szz} ${sxy} ${sxz} ${syz}" screen no file dump.stat 47 | dump posdump all custom 100 dump.positions xs ys zs 48 | dump forcedump all custom 100 dump.forces fx fy fz 49 | dump_modify posdump format "%20.15e %20.15e %20.15e" 50 | dump_modify forcedump format "%20.15e %20.15e %20.15e" 51 | ``` 52 | 53 | The frequency of the dumps and so on can of course be adjusted. Make sure you use [generate structure](../program/generate_structure.html) to create the LAMMPS cell file, since it will also create structure input files in the format TDEP needs. These dump files are not exactly the correct format. A small script can rearrange it to the correct format: 54 | 55 | ```bash 56 | #!/bin/bash 57 | 58 | # figure out how many atoms there are 59 | na=`head -n 4 dump.forces | tail -n 1` 60 | # remove the header from the stat file 61 | grep -v '^#' dump.stat > infile.stat 62 | # figure out how many timesteps there are 63 | nt=`wc -l infile.stat | awk '{print $1}'` 64 | 65 | # create the positions and force files 66 | [ -f infile.forces ] && rm infile.forces 67 | [ -f infile.positions ] && rm infile.positions 68 | for t in `seq 1 ${nt}` 69 | do 70 | nl=$(( ${na}+9)) 71 | nll=$(( ${nl}*${t} )) 72 | echo "t ${t} ${nl} ${nll}" 73 | head -n ${nll} dump.forces | tail -n ${na} >> infile.forces 74 | head -n ${nll} dump.positions | tail -n ${na} >> infile.positions 75 | done 76 | ``` 77 | 78 | There are probably far better ways of doing this, happy to take any suggestions. 79 | -------------------------------------------------------------------------------- /examples/build/important_settings.cgal: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # A central place to put all the important paths. You probably have to modify this to make things work. 3 | 4 | # the fortran compiler 5 | FORTRAN_COMPILER="gfortran-13" 6 | # required compiler flags 7 | FCFLAGS="-ffree-line-length-none -std=f2008 -cpp -fallow-argument-mismatch" 8 | # extra flags, for debugging and such 9 | FCFLAGS_EXTRA="" 10 | # FCFLAGS_EXTRA="-g -fbacktrace -fcheck=all -finit-real=nan -finit-derived -fmax-errors=10 --pedantic --warn-all" 11 | # FCFLAGS_EXTRA="-g -fbacktrace -fcheck=all -finit-real=nan -finit-derived -fmax-errors=10 --pedantic -Wall -Wextra -pedantic -Wcast-align -Wdisabled-optimization -Wmissing-include-dirs -Wshadow -Wunused -fdiagnostics-show-option -fcheck=all -Wstrict-overflow=0 -Wrealloc-lhs" 12 | 13 | # optimization stuff. Go all in, sometimes 14 | # OPTIMIZATION_LEVEL="-Ofast" 15 | OPTIMIZATION_LEVEL="-O3" 16 | # OPTIMIZATION_LEVEL="-O0" 17 | OPTIMIZATION_SENSITIVE="-O0" 18 | 19 | # the flag that sets the default real to a double. 20 | DOUBLE_FLAG="-fdefault-real-8" 21 | # The flag that tells the compiler where to put .o and .mod files. 22 | MODULE_FLAG="-J" 23 | 24 | # the header to put in python scripts. 25 | PYTHONHEADER="#!/usr/bin/env python" 26 | 27 | # Which gnuplot terminal to use by default. 28 | GNUPLOTTERMINAL="aqua" # nice on OSX, needs aquaterm installed and gnuplot compiled with support for it. 29 | 30 | # Precompiler flags. Selecting default gnuplot terminal, and make the progressbars work. 31 | PRECOMPILER_FLAGS="-DGP${GNUPLOTTERMINAL} -Dclusterprogressbar" 32 | # PRECOMPILER_FLAGS="-DGP${GNUPLOTTERMINAL} -Dclusterprogressbar -DAGRESSIVE_SANITY" 33 | #PRECOMPILER_FLAGS="-DGP${GNUPLOTTERMINAL} -Dgfortranprogressbar" 34 | #PRECOMPILER_FLAGS="-DGP${GNUPLOTTERMINAL} -Dgfortranprogressbar -DAGRESSIVE_SANITY" 35 | 36 | # These are the BLAS/LAPACK libraries. On OSX with gfortran, use the built-in 'framework accelerate' 37 | PATH_TO_BLASLAPACK_LIB="" 38 | PATH_TO_BLASLAPACK_INC="" 39 | BLASLAPACK_LIBS="-framework accelerate" 40 | 41 | # I use fftw for Fourier transforms. 42 | PATH_TO_FFTW_LIB="-L/opt/homebrew/lib" 43 | PATH_TO_FFTW_INC="-I/opt/homebrew/include" 44 | FFTW_LIBS="" 45 | FFTW_LIBS="-lfftw3" 46 | 47 | # Also need MPI 48 | PATH_TO_MPI_LIB="-L/opt/homebrew/lib" 49 | PATH_TO_MPI_INC="-I/opt/homebrew/include" 50 | MPI_LIBS="-lmpi_mpifh -lmpi" 51 | 52 | # I also use HDF5 every now and then 53 | PATH_TO_HDF5_LIB="-L/Users/flokno/local/hdf5-1.12.2/build_2022_11/lib" 54 | PATH_TO_HDF5_INC="-I/Users/flokno/local/hdf5-1.12.2/build_2022_11/include" 55 | HDF5_LIBS="-lhdf5 -lhdf5_fortran" 56 | 57 | # Optionally CGAL and FHI-Aims. You probably do not want that. 58 | USEAIMS="no" 59 | 60 | # Let's do it 61 | USECGAL="yes" 62 | 63 | CGAL_PATH=/Users/flokno/local/cgal-5.6.1/build 64 | 65 | # CGAL is written in c++. I have wrapper functions in C, that I call from Fortran. 66 | CPP_COMPILER="gcc-13" 67 | CPP_FLAGS="--std=c++14 -frounding-math -O3 -Dusecgal -DCGAL_USE_GMP -DCGAL_USE_MPFR -DCGAL_EIGEN3_ENABLED -DNDEBUG -DBOOST_PARAMETER_MAX_ARITY=12 -Wno-deprecated-declarations" 68 | CGALLINKLINE="-lstdc++ -lmpfr -lgmp -lboost_system -lboost_thread-mt" 69 | # CGALLINKLINE="-lCGAL -lCGAL_Core" # -lmpfr -lgmp -lboost_system -lboost_thread-mt" 70 | # CGALLINKLINE="-lstdc++ -lCGAL -lCGAL_Core -lmpfr -lgmp -lboost_system -lboost_thread-mt" 71 | # CGALLINKLINE="-lstdc++ -lCGAL -lCGAL_Core -lmpfr -lgmp -lboost_system -lboost_thread-mt" 72 | 73 | PATH_TO_CGAL_LIB="-L$CGAL_PATH/lib" 74 | PATH_TO_CGAL_INC="-I$CGAL_PATH/include/ -I/opt/homebrew/include/eigen3 -I/opt/homebrew/include" 75 | 76 | -------------------------------------------------------------------------------- /CITATION.cff: -------------------------------------------------------------------------------- 1 | cff-version: "1.2.0" 2 | authors: 3 | - family-names: Knoop 4 | given-names: Florian 5 | orcid: "https://orcid.org/0000-0002-7132-039X" 6 | - family-names: Shulumba 7 | given-names: Nina 8 | orcid: "https://orcid.org/0000-0002-2374-7487" 9 | - family-names: Castellano 10 | given-names: Aloïs 11 | orcid: "https://orcid.org/0000-0002-8783-490X" 12 | - family-names: Batista 13 | given-names: J. P. Alvarinhas 14 | orcid: "https://orcid.org/0000-0002-3314-249X" 15 | - family-names: Farris 16 | given-names: Roberta 17 | orcid: "https://orcid.org/0000-0001-6710-0100" 18 | - family-names: Verstraete 19 | given-names: Matthieu J. 20 | orcid: "https://orcid.org/0000-0001-6921-5163" 21 | - family-names: Heine 22 | given-names: Matthew 23 | orcid: "https://orcid.org/0000-0002-4882-6712" 24 | - family-names: Broido 25 | given-names: David 26 | orcid: "https://orcid.org/0000-0003-0182-4450" 27 | - family-names: Kim 28 | given-names: Dennis S. 29 | orcid: "https://orcid.org/0000-0002-5707-2609" 30 | - family-names: Klarbring 31 | given-names: Johan 32 | orcid: "https://orcid.org/0000-0002-6223-5812" 33 | - family-names: Abrikosov 34 | given-names: Igor A. 35 | orcid: "https://orcid.org/0000-0001-7551-4717" 36 | - family-names: Simak 37 | given-names: Sergei I. 38 | orcid: "https://orcid.org/0000-0002-1320-389X" 39 | - family-names: Hellman 40 | given-names: Olle 41 | orcid: "https://orcid.org/0000-0002-3453-2975" 42 | doi: 10.5281/zenodo.10589895 43 | message: If you use this software, please cite our article in the 44 | Journal of Open Source Software. 45 | preferred-citation: 46 | authors: 47 | - family-names: Knoop 48 | given-names: Florian 49 | orcid: "https://orcid.org/0000-0002-7132-039X" 50 | - family-names: Shulumba 51 | given-names: Nina 52 | orcid: "https://orcid.org/0000-0002-2374-7487" 53 | - family-names: Castellano 54 | given-names: Aloïs 55 | orcid: "https://orcid.org/0000-0002-8783-490X" 56 | - family-names: Batista 57 | given-names: J. P. Alvarinhas 58 | orcid: "https://orcid.org/0000-0002-3314-249X" 59 | - family-names: Farris 60 | given-names: Roberta 61 | orcid: "https://orcid.org/0000-0001-6710-0100" 62 | - family-names: Verstraete 63 | given-names: Matthieu J. 64 | orcid: "https://orcid.org/0000-0001-6921-5163" 65 | - family-names: Heine 66 | given-names: Matthew 67 | orcid: "https://orcid.org/0000-0002-4882-6712" 68 | - family-names: Broido 69 | given-names: David 70 | orcid: "https://orcid.org/0000-0003-0182-4450" 71 | - family-names: Kim 72 | given-names: Dennis S. 73 | orcid: "https://orcid.org/0000-0002-5707-2609" 74 | - family-names: Klarbring 75 | given-names: Johan 76 | orcid: "https://orcid.org/0000-0002-6223-5812" 77 | - family-names: Abrikosov 78 | given-names: Igor A. 79 | orcid: "https://orcid.org/0000-0001-7551-4717" 80 | - family-names: Simak 81 | given-names: Sergei I. 82 | orcid: "https://orcid.org/0000-0002-1320-389X" 83 | - family-names: Hellman 84 | given-names: Olle 85 | orcid: "https://orcid.org/0000-0002-3453-2975" 86 | date-published: 2024-02-01 87 | doi: 10.21105/joss.06150 88 | issn: 2475-9066 89 | issue: 94 90 | journal: Journal of Open Source Software 91 | publisher: 92 | name: Open Journals 93 | start: 6150 94 | title: "TDEP: Temperature Dependent Effective Potentials" 95 | type: article 96 | url: "https://joss.theoj.org/papers/10.21105/joss.06150" 97 | volume: 9 98 | title: "TDEP: Temperature Dependent Effective Potentials" 99 | 100 | -------------------------------------------------------------------------------- /examples/build/important_settings.marenostrum5: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # A central place to put all the important paths. You probably have to modify this to make things work. 3 | 4 | #The following modules and env variables are needed on MN5: 5 | #module purge 6 | #module load gcc/12.3.0 7 | #module load openmpi/4.1.5-gcc 8 | #module load libxc/6.2.0-gcc-kxc 9 | #module load hdf5/1.14.1-2-gcc-openmpi 10 | #module load pnetcdf/1.12.3-gcc-openmpi 11 | #module load netcdf/c-4.9.2_fortran-4.6.1_cxx4-4.3.1_hdf5-1.14.1-2_pnetcdf-1.12.3-gcc-openmpi 12 | #module load mkl/2024.2 13 | #module load lapack/3.12-gcc 14 | #module load scalapack/2.2.0-gcc-openmpi 15 | #module load fftw/3.3.10-gcc-ompi 16 | #CC=mpicc 17 | #CXX=mpicxx 18 | 19 | 20 | # the fortran compiler 21 | FORTRAN_COMPILER="mpifort" 22 | # required compiler flags 23 | FCFLAGS="-ffree-line-length-none -std=f2008 -cpp" 24 | # extra flags, for debugging and such 25 | FCFLAGS_EXTRA="" 26 | #FCFLAGS_EXTRA="-fbacktrace -fcheck=all -finit-real=nan -finit-derived -fmax-errors=10 --pedantic -Wall -Wextra -pedantic -Wcast-align -Wdisabled-optimization -Wmissing-include-dirs -Wshadow -Wunused -fdiagnostics-show-option -fcheck=all -Wstrict-overflow=0 -Wrealloc-lhs" 27 | 28 | # optimization stuff. Go all in, sometimes 29 | OPTIMIZATION_LEVEL="-O3" 30 | #OPTIMIZATION_SENSITIVE="-O0" 31 | 32 | # the flag that sets the default real to a double. 33 | DOUBLE_FLAG="-fdefault-real-8" 34 | # The flag that tells the compiler where to put .o and .mod files. 35 | MODULE_FLAG="-J" 36 | 37 | # the header to put in python scripts. 38 | PYTHONHEADER="#!/usr/bin/python" 39 | 40 | # Which gnuplot terminal to use by default. 41 | GNUPLOTTERMINAL="x11" # nice on OSX, needs aquaterm installed and gnuplot compiled with support for it. 42 | 43 | # Precompiler flags. Selecting default gnuplot terminal, and make the progressbars work. 44 | PRECOMPILER_FLAGS="-DGP${GNUPLOTTERMINAL} -Dgfortranprogressbar" 45 | 46 | # These are the BLAS/LAPACK libraries. On OSX with gfortran, use the built-in 'framework accelerate' 47 | PATH_TO_BLASLAPACK_LIB="-L/gpfs/apps/MN5/GPP/LAPACK/3.12/GCC/lib64" 48 | PATH_TO_BLASLAPACK_INC="-I/gpfs/apps/MN5/GPP/LAPACK/3.12/GCC/include" 49 | BLASLAPACK_LIBS="-llapack -lblas" 50 | 51 | # I use fftw for Fourier transforms. 52 | PATH_TO_FFTW_LIB="-L/gpfs/apps/MN5/GPP/FFTW/3.3.10/GCC/OPENMPI/lib" 53 | PATH_TO_FFTW_INC="-I/gpfs/apps/MN5/GPP/FFTW/3.3.10/GCC/OPENMPI/include" 54 | #FFTW_LIBS="-lfftw3f_mpi -lfftw3f_threads -lfftw3f -lfftw3_mpi -lfftw3_threads -lfftw3" 55 | FFTW_LIBS="-lfftw3" 56 | 57 | # Also need MPI 58 | PATH_TO_MPI_LIB="-L/gpfs/apps/MN5/GPP/OPENMPI/4.1.5/GCC/lib" 59 | PATH_TO_MPI_INC="-I/gpfs/apps/MN5/GPP/OPENMPI/4.1.5/GCC/include" 60 | MPI_LIBS="-lmpi_mpifh -lmpi" 61 | 62 | # I also use HDF5 every now and then 63 | PATH_TO_HDF5_LIB="-L/gpfs/apps/MN5/GPP/HDF5/1.14.1-2/GCC/OPENMPI/lib" 64 | PATH_TO_HDF5_INC="-I/gpfs/apps/MN5/GPP/HDF5/1.14.1-2/GCC/OPENMPI/include" 65 | HDF5_LIBS="-lhdf5 -lhdf5_fortran" 66 | #HDF5_LIBS="-lhdf5_hl_parallel -lhdf5_parallel -lhdf5hl_fortran_parallel -lhdf5_fortran_parallel" 67 | 68 | # We also need a C-compiler 69 | C_COMPILER="mpicc" 70 | C_FLAGS="" 71 | 72 | # CGAL is written in c++. I have wrapper functions in C, that I call from Fortran. 73 | #CPP_COMPILER="mpicxx" 74 | #CPP_FLAGS="--std=c++0x -frounding-math -O3" 75 | 76 | # Things below this line is strictly optional, and not really needed except for testing purposes. 77 | # If you want to try and use CGAL. Not recommended for people who do not like to sort out compiler errors. 78 | USECGAL="no" 79 | USEAIMS="no" 80 | -------------------------------------------------------------------------------- /src/lineshape/Makefile: -------------------------------------------------------------------------------- 1 | include Makefile.inc 2 | CODE = lineshape 3 | PROG = ../../build/$(CODE)/$(CODE) 4 | OBJECT_PATH=../../build/$(CODE)/ 5 | 6 | OBJS = $(OBJECT_PATH)main.o\ 7 | $(OBJECT_PATH)options.o\ 8 | $(OBJECT_PATH)io.o\ 9 | $(OBJECT_PATH)scatteringrates.o\ 10 | $(OBJECT_PATH)phonondamping.o\ 11 | $(OBJECT_PATH)phonondamping_aux.o\ 12 | $(OBJECT_PATH)phonondamping_dos.o\ 13 | $(OBJECT_PATH)phonondamping_grid.o\ 14 | $(OBJECT_PATH)phonondamping_path.o\ 15 | $(OBJECT_PATH)dielscatter.o\ 16 | $(OBJECT_PATH)dielscatter_helper.o\ 17 | $(OBJECT_PATH)lineshape_helper.o\ 18 | $(OBJECT_PATH)lo_realspace_selfenergy.o\ 19 | $(OBJECT_PATH)lo_thermal_transport.o 20 | 21 | LPATH = -L../../lib $(blaslapackLPATH) $(incLPATHhdf) $(incLPATHmpi) $(incLPATHfft) 22 | IPATH = -I../../inc/libolle -I../../inc/libflap $(blaslapackIPATH) ${incIPATHhdf} $(incIPATHmpi) $(incIPATHfft) 23 | LIBS = ../../lib/libolle.a -lflap $(blaslapackLIBS) ${incLIBShdf} $(incLIBSmpi) $(incLIBSfft) 24 | 25 | #OPT = -Ofast 26 | #OPT = -O0 -fbacktrace -fcheck=all -finit-real=nan -finit-derived -fmax-errors=10 -Wall 27 | F90 = $(FC) $(LPATH) $(IPATH) $(MODULE_FLAG) $(OBJECT_PATH) #$(warnings_gcc) 28 | F90FLAGS = $(OPT) $(MODS) $(LIBS) 29 | 30 | all: $(PROG) 31 | 32 | $(PROG): $(OBJS) 33 | $(F90) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) 34 | 35 | clean: 36 | rm -f $(PROG) $(OBJS) $(OBJECT_PATH)*.mod 37 | 38 | $(OBJECT_PATH)main.o:\ 39 | $(OBJECT_PATH)options.o\ 40 | $(OBJECT_PATH)io.o\ 41 | $(OBJECT_PATH)scatteringrates.o\ 42 | $(OBJECT_PATH)phonondamping.o\ 43 | $(OBJECT_PATH)dielscatter.o\ 44 | $(OBJECT_PATH)lineshape_helper.o\ 45 | $(OBJECT_PATH)lo_realspace_selfenergy.o\ 46 | $(OBJECT_PATH)lo_thermal_transport.o 47 | $(F90) $(F90FLAGS) -c main.f90 $(LIBS) -o $@ 48 | $(OBJECT_PATH)io.o: $(OBJECT_PATH)phonondamping.o $(OBJECT_PATH)dielscatter.o $(OBJECT_PATH)lineshape_helper.o 49 | $(F90) $(F90FLAGS) -c io.f90 $(LIBS) -o $@ 50 | $(OBJECT_PATH)phonondamping.o:\ 51 | phonondamping.f90\ 52 | $(OBJECT_PATH)scatteringrates.o\ 53 | $(OBJECT_PATH)options.o\ 54 | $(OBJECT_PATH)lineshape_helper.o\ 55 | $(OBJECT_PATH)lo_realspace_selfenergy.o\ 56 | $(OBJECT_PATH)lo_thermal_transport.o 57 | $(F90) $(F90FLAGS) -c phonondamping.f90 $(LIBS) -o $@ 58 | $(OBJECT_PATH)phonondamping_aux.o: $(OBJECT_PATH)phonondamping.o 59 | $(F90) $(F90FLAGS) -c phonondamping_aux.f90 $(LIBS) -o $@ 60 | $(OBJECT_PATH)phonondamping_dos.o: $(OBJECT_PATH)phonondamping.o 61 | $(F90) $(F90FLAGS) -c phonondamping_dos.f90 $(LIBS) -o $@ 62 | $(OBJECT_PATH)phonondamping_grid.o: $(OBJECT_PATH)phonondamping.o 63 | $(F90) $(F90FLAGS) -c phonondamping_grid.f90 $(LIBS) -o $@ 64 | $(OBJECT_PATH)phonondamping_path.o: $(OBJECT_PATH)phonondamping.o 65 | $(F90) $(F90FLAGS) -c phonondamping_path.f90 $(LIBS) -o $@ 66 | $(OBJECT_PATH)scatteringrates.o: $(OBJECT_PATH)lineshape_helper.o 67 | $(F90) $(F90FLAGS) -c scatteringrates.f90 $(LIBS) -o $@ 68 | $(OBJECT_PATH)dielscatter.o:\ 69 | dielscatter.f90\ 70 | $(OBJECT_PATH)options.o\ 71 | $(OBJECT_PATH)phonondamping.o\ 72 | $(OBJECT_PATH)lineshape_helper.o 73 | $(F90) $(F90FLAGS) -c dielscatter.f90 $(LIBS) -o $@ 74 | $(OBJECT_PATH)dielscatter_helper.o: $(OBJECT_PATH)dielscatter.o 75 | $(F90) $(F90FLAGS) -c dielscatter_helper.f90 $(LIBS) -o $@ 76 | $(OBJECT_PATH)lineshape_helper.o:\ 77 | lineshape_helper.f90 78 | $(F90) $(F90FLAGS) -c lineshape_helper.f90 $(LIBS) -o $@ 79 | $(OBJECT_PATH)lo_realspace_selfenergy.o: 80 | $(F90) $(F90FLAGS) -c lo_realspace_selfenergy.f90 $(LIBS) -o $@ 81 | $(OBJECT_PATH)lo_thermal_transport.o: $(OBJECT_PATH)lineshape_helper.o 82 | $(F90) $(F90FLAGS) -c lo_thermal_transport.f90 $(LIBS) -o $@ 83 | $(OBJECT_PATH)options.o: 84 | $(F90) $(F90FLAGS) -c options.f90 $(LIBS) -o $@ 85 | -------------------------------------------------------------------------------- /examples/build/important_settings.osx_gfortran_accelerate: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # A central place to put all the important paths. You probably have to modify this to make things work. 3 | 4 | # the fortran compiler 5 | FORTRAN_COMPILER="gfortran-8" 6 | # required compiler flags 7 | FCFLAGS="-ffree-line-length-none -std=f2008 -cpp" 8 | # extra flags, for debugging and such 9 | FCFLAGS_EXTRA="" 10 | #FCFLAGS_EXTRA="-fbacktrace -fcheck=all -finit-real=nan -finit-derived -fmax-errors=10 --pedantic --warn-all" 11 | #FCFLAGS_EXTRA="-fbacktrace -fcheck=all -finit-real=nan -finit-derived -fmax-errors=10 --pedantic -Wall -Wextra -pedantic -Wcast-align -Wdisabled-optimization -Wmissing-include-dirs -Wshadow -Wunused -fdiagnostics-show-option -fcheck=all -Wstrict-overflow=0 -Wrealloc-lhs" 12 | 13 | # optimization stuff. Go all in, sometimes 14 | OPTIMIZATION_LEVEL="-Ofast" 15 | OPTIMIZATION_SENSITIVE="-O0" 16 | 17 | # the flag that sets the default real to a double. 18 | DOUBLE_FLAG="-fdefault-real-8" 19 | # The flag that tells the compiler where to put .o and .mod files. 20 | MODULE_FLAG="-J" 21 | 22 | # the header to put in python scripts. 23 | PYTHONHEADER="#!/usr/bin/python" 24 | 25 | # Which gnuplot terminal to use by default. 26 | # Choices: aqua, qt, wxt 27 | GNUPLOTTERMINAL="aqua" # nice on OSX, needs aquaterm installed and gnuplot compiled with support for it. 28 | 29 | # Precompiler flags. Selecting default gnuplot terminal, and make the progressbars work. 30 | #PRECOMPILER_FLAGS="-DGP${GNUPLOTTERMINAL} -Dclusterprogressbar" 31 | PRECOMPILER_FLAGS="-DGP${GNUPLOTTERMINAL} -Dgfortranprogressbar" 32 | #PRECOMPILER_FLAGS="-DGP${GNUPLOTTERMINAL} -Dgfortranprogressbar -DAGRESSIVE_SANITY" 33 | 34 | # These are the BLAS/LAPACK libraries. On OSX with gfortran, use the built-in 'framework accelerate' 35 | PATH_TO_BLASLAPACK_LIB="" 36 | PATH_TO_BLASLAPACK_INC="" 37 | BLASLAPACK_LIBS="-framework accelerate" 38 | 39 | # I use fftw for Fourier transforms. 40 | PATH_TO_FFTW_LIB="-L/usr/local/lib" 41 | PATH_TO_FFTW_INC="-I/usr/local/include" 42 | FFTW_LIBS="-lfftw3" 43 | 44 | # Also need MPI 45 | PATH_TO_MPI_LIB="-L/usr/local/lib" 46 | PATH_TO_MPI_INC="-I/usr/local/include" 47 | MPI_LIBS="-lmpi_mpifh -lmpi" 48 | 49 | # I also use HDF5 every now and then 50 | PATH_TO_HDF5_LIB="-L/usr/local/lib" 51 | PATH_TO_HDF5_INC="-I/usr/local/include" 52 | HDF5_LIBS="-lhdf5 -lhdf5_fortran" 53 | 54 | # We also need a C-compiler 55 | C_COMPILER="gcc-8" 56 | C_FLAGS="" 57 | 58 | # Things below this line is strictly optional, and not really needed except for testing purposes. 59 | # If you want to try and use CGAL. Not recommended for people who do not like to sort out compiler errors. 60 | USECGAL="no" 61 | USEAIMS="no" 62 | 63 | # CGAL is written in c++. I have wrapper functions in C, that I call from Fortran. 64 | CPP_COMPILER="gcc-8" 65 | CPP_FLAGS="--std=c++0x -frounding-math -O3 -Dusecgal -DCGAL_USE_GMP -DCGAL_USE_MPFR -DCGAL_EIGEN3_ENABLED -DNDEBUG -DBOOST_PARAMETER_MAX_ARITY=12 -Wno-deprecated-declarations" 66 | CGALLINKLINE="-lstdc++ -lCGAL -lmpfr -lgmp -lboost_system -lboost_thread-mt" 67 | 68 | # It's important at least a majority of these libraries are compiled with the same c++ compiler 69 | # as above. You can get strange, strange errors otherwise. As I said, getting this up and running 70 | # is not easy. 71 | PATH_TO_CGAL_LIB="-L/Users/olle/software/CGAL-4.11.2/build/lib -L/usr/local/lib" 72 | PATH_TO_CGAL_INC="-I/Users/olle/software/CGAL-4.11.2/build/include -I/usr/local/include -I/usr/local/include/eigen3" 73 | 74 | # include AIMS things 75 | PATH_TO_AIMS_LIB="-L/Users/olle/software/aims/src/build/lib" 76 | PATH_TO_AIMS_INC="-I/Users/olle/software/aims/src/build/include" 77 | AIMS_LIBS="-laims.180920.hdf5.scalapack.mpi -lscalapack" 78 | -------------------------------------------------------------------------------- /src/libolle/type_lennardjones.f90: -------------------------------------------------------------------------------- 1 | #include "precompilerdefinitions" 2 | module type_lennardjones 3 | !! Lennard-Jones interatomic potential 4 | use konstanter, only: flyt 5 | implicit none 6 | 7 | private 8 | public :: lo_lj 9 | 10 | !> lennard-jones force-field 11 | type lo_lj 12 | !> sigma 13 | real(flyt) :: sig 14 | real(flyt) :: eps 15 | !> soft cutoff 16 | real(flyt) :: rc1 17 | !> hard cutoff 18 | real(flyt) :: rc2 19 | !> some shorthand 20 | real(flyt) :: A 21 | real(flyt) :: B 22 | real(flyt) :: twelveA 23 | real(flyt) :: sixB 24 | ! spline coefficients 25 | real(flyt) :: cA,cB,cC,cD 26 | real(flyt) :: c0,c1,c2,c3,c4,c5 27 | real(flyt) :: ljshift 28 | ! 29 | contains 30 | !> generate spline coefficients and things 31 | procedure :: setup 32 | end type 33 | 34 | contains 35 | 36 | !> precalculate as much as possible 37 | subroutine setup(lj,cutoff,sigma,eps) 38 | !> the Lennard-Jones potential 39 | class(lo_lj), intent(out) :: lj 40 | !> some parameters 41 | real(flyt), intent(in) :: cutoff,sigma,eps 42 | ! 43 | real(flyt) :: x1,x2,V1,V2,V3,dx 44 | ! 45 | lj%eps=eps ! no idea, picked one at random 46 | lj%sig=sigma ! no idea, also random 47 | ! 48 | ! it's neat to convert these to just two number, to the form 49 | ! A/r^12-B/r^6 50 | ! 51 | lj%A=4.0_flyt*lj%eps*(lj%sig**12) 52 | lj%B=4.0_flyt*lj%eps*(lj%sig**6) 53 | lj%twelveA=12.0_flyt*lj%A ! just to not have to do the multiplication all the time 54 | lj%sixB=6.0_flyt*lj%B ! same here 55 | ! 56 | ! It's good to not have a hard cutoff, but smoothly join it to 0 with a cubic spline. Makes things a lot 57 | ! more robust with forces and energies that are continous across space. 58 | ! 59 | lj%rc2=cutoff 60 | ! 61 | ! the soft cutoff, where I switch to a spline. I make it a little smaller than the hard, by a random number. 62 | ! this value should be checked that it does not give strange results. 63 | ! 64 | lj%rc1=cutoff-0.25_flyt 65 | ! the spline coefficients (thanks mathematica) 66 | !A -> -((2*V1 - V2*x1 + V2*x2)/(x1 - x2)^3) 67 | !B -> -((-3*V1*x1 + V2*x1^2 - 3*V1*x2 + V2*x1*x2 - 2*V2*x2^2)/(x1 - x2)^3) 68 | !C -> (x2*(-6*V1*x1 + 2*V2*x1^2 - V2*x1*x2 - V2*x2^2))/(x1 - x2)^3 69 | !D -> -((-3*V1*x1*x2^2 + V2*x1^2*x2^2 + V1*x2^3 - V2*x1*x2^3)/(x1 - x2)^3)}} 70 | x1=lj%rc1 71 | x2=lj%rc2 72 | lj%ljshift=lj%A/(x2**12)-lj%B/(x2**6) ! lift the energies 73 | dx=x1-x2 74 | V1=lj%A/(x1**12)-lj%B/(x1**6)-lj%ljshift 75 | V2=-12.0_flyt*lj%A/(x1**13)+6*lj%B/(x1**7) 76 | V3=156*lj%A/(x1**14)-42*lj%B/(x1**8) 77 | ! 78 | lj%cA = -((2*V1 - V2*x1 + V2*x2)/(x1 - x2)**3) 79 | lj%cB = -((-3*V1*x1 + V2*x1**2 - 3*V1*x2 + V2*x1*x2 - 2*V2*x2**2)/(x1 - x2)**3) 80 | lj%cC = (x2*(-6*V1*x1 + 2*V2*x1**2 - V2*x1*x2 - V2*x2**2))/(x1 - x2)**3 81 | lj%cD = -((-3*V1*x1*x2**2 + V2*x1**2*x2**2 + V1*x2**3 - V2*x1*x2**3)/(x1 - x2)**3) 82 | ! 83 | lj%c0=-((x2**3*(2*V1*(10*x1**2-5*x1*x2+x2**2)+dx*x1*(dx*V3*x1+2*V2*(-4*x1+x2))))/(2*dx**5)) 84 | lj%c1=(x2**2*(60*V1*x1**2-dx*(2*V2*(6*x1-x2)*(2*x1+x2)+V3*x1*(-3*x1**2+x1*x2+2*x2**2))))/(2*dx**5) 85 | lj%c2=(x2*(-60*V1*x1*(x1+x2)+dx*(12*V2*x1*(2*x1+3*x2)-dx*V3*(3*x1**2+6*x1*x2+x2**2))))/(2*dx**5) 86 | lj%c3=(20*V1*(x1**2+4*x1*x2+x2**2)+dx*(dx*V3*(x1**2+6*x1*x2+3*x2**2)-4*V2*(2*x1**2+10*x1*x2+3*x2**2)))/(2*dx**5) 87 | lj%c4=(-30*V1*(x1+x2)+dx*(-dx*V3*(2*x1+3*x2)+2*V2*(7*x1+8*x2)))/(2*dx**5) 88 | lj%c5=(12*V1+dx*(-6*V2+dx*V3))/(2*dx**5) 89 | 90 | ! Square the cutoffs 91 | lj%rc1=lj%rc1**2 92 | lj%rc2=lj%rc2**2 93 | 94 | ! 95 | end subroutine 96 | 97 | 98 | end module 99 | -------------------------------------------------------------------------------- /src/refine_structure/options.f90: -------------------------------------------------------------------------------- 1 | #include "precompilerdefinitions" 2 | module options 3 | use konstanter, only: r8, lo_status, lo_author, lo_version, lo_licence, lo_huge 4 | use flap, only: command_line_interface 5 | implicit none 6 | 7 | private 8 | public :: lo_opts 9 | 10 | type lo_opts 11 | !> tolerance 12 | real(r8) :: tolerance_lattice = -lo_huge 13 | real(r8) :: tolerance_internal = -lo_huge 14 | !> unitcell filename 15 | character(len=2000) :: unitcell_filename 16 | !> supercell filename 17 | character(len=2000) :: supercell_filename 18 | !> prototype unitcell filename 19 | character(len=2000) :: prototype_unitcell 20 | !> how much to talk 21 | integer :: verbosity 22 | contains 23 | procedure :: parse 24 | end type 25 | 26 | contains 27 | 28 | subroutine parse(opts) 29 | !> the options 30 | class(lo_opts), intent(out) :: opts 31 | !> the helper parser 32 | type(command_line_interface) :: cli 33 | 34 | logical :: dumlog 35 | 36 | call cli%init(progname='refine_structure', & 37 | authors=lo_author, & 38 | version=lo_version, & 39 | license=lo_licence, & 40 | help='Usage: ', & 41 | description='Small utility to ensure that the input structure satisfies all symmetries to high precision.', & 42 | examples=["refine_structure"], & 43 | epilog=new_line('a')//"...") 44 | cli_manpage 45 | cli_verbose 46 | call cli%add(switch='--tolerance_lattice', switch_ab='-tl', & 47 | help='Tolerance for the lattice.', & 48 | required=.false., act='store', def='1E-5', error=lo_status) 49 | if (lo_status .ne. 0) stop 50 | call cli%add(switch='--tolerance_internal', switch_ab='-ti', & 51 | help='Tolerance for internal degrees of freedom.', & 52 | required=.false., act='store', def='1E-5', error=lo_status) 53 | if (lo_status .ne. 0) stop 54 | call cli%add(switch='--unitcell', switch_ab='-uc', & 55 | help='Filename for the unitcell to refine.', & 56 | required=.false., act='store', def='infile.ucposcar', error=lo_status) 57 | if (lo_status .ne. 0) stop 58 | call cli%add(switch='--supercell', switch_ab='-ss', & 59 | help='Filename for supercell to refine.', & 60 | required=.false., act='store', def='none', error=lo_status) 61 | if (lo_status .ne. 0) stop 62 | call cli%add(switch='--prototype', switch_ab='-pf', & 63 | help='Prototype unitcell where you know the symmetry is correct.', & 64 | required=.false., act='store', def='none', error=lo_status) 65 | if (lo_status .ne. 0) stop 66 | 67 | ! actually parse it 68 | call cli%parse(error=lo_status) 69 | if (lo_status .ne. 0) stop 70 | 71 | ! generate manpage? 72 | call cli%get(switch='--manpage', val=dumlog) 73 | if (dumlog) then 74 | call cli%save_man_page(trim(cli%progname)//'.1') 75 | call cli%save_usage_to_markdown(trim(cli%progname)//'.md') 76 | write (*, *) 'Wrote manpage for "'//trim(cli%progname)//'"' 77 | stop 78 | end if 79 | opts%verbosity = 0 80 | call cli%get(switch='--verbose', val=dumlog) 81 | if (dumlog) opts%verbosity = 2 82 | 83 | ! Parse the rest 84 | call cli%get(switch='--tolerance_internal', val=opts%tolerance_internal, error=lo_status) 85 | call cli%get(switch='--tolerance_lattice', val=opts%tolerance_lattice, error=lo_status) 86 | call cli%get(switch='--unitcell', val=opts%unitcell_filename, error=lo_status) 87 | call cli%get(switch='--supercell', val=opts%supercell_filename, error=lo_status) 88 | call cli%get(switch='--prototype', val=opts%prototype_unitcell, error=lo_status) 89 | 90 | end subroutine 91 | 92 | end module 93 | -------------------------------------------------------------------------------- /src/libolle/precompilerdefinitions: -------------------------------------------------------------------------------- 1 | #define lo_allocate(statement) allocate(statement) 2 | 3 | #define lo_deallocate(statement) deallocate(statement,stat=lo_status); if ( lo_status .ne. 0 ) then; write(*,*) ' '; write(*,*) 'PRÖBLÄM'; write(*,*) 'Failed deallocating in: ',__FILE__,' on line: ',__LINE__; write(*,*) 'stopped'; stop; endif 4 | 5 | #define cli_unit call cli%add(switch='--unit',help='Choose the output unit. The options are terahertz (in frequency, not angular frequency), inverse cm or meV.',required=.false.,act='store',def='thz',choices='thz,mev,icm',error=lo_status); if ( lo_status .ne. 0 ) stop 6 | 7 | #define cli_nq_on_path call cli%add(switch='--nq_on_path',switch_ab='-nq',help='Number of q-points between each high symmetry point',required=.false.,act='store',def='100',error=lo_status); if ( lo_status .ne. 0 ) stop 8 | 9 | #define cli_readpath call cli%add(switch='--readpath',switch_ab='-rp', help='Read the q-point path from `infile.qpoints_dispersion`.',help_markdown='Use [crystal structure into](crystal_structure_info.html) to generate an example.',required=.false.,act='store_true',def='.false.',error=lo_status); if ( lo_status .ne. 0 ) stop 10 | 11 | #define cli_qpoint_grid call cli%add(switch='--qpoint_grid',switch_ab='-qg',help='Density of q-point mesh for Brillouin zone integrations.',nargs='3',required=.false.,act='store',def='26 26 26',error=lo_status); if ( lo_status .ne. 0 ) stop 12 | 13 | #define cli_meshtype call cli%add(switch='--meshtype',help='Type of q-point mesh. 1 Is a Monkhorst-Pack mesh, 2 an FFT mesh and 3 my fancy wedge-based mesh with approximately the same density the grid-based meshes. 4 build the commensurate mesh of an approximately cubic supercell.',required=.false.,act='store',def='1',choices='1,2,3,4',error=lo_status); if ( lo_status .ne. 0 ) stop 14 | 15 | #define cli_sigma call cli%add(switch='--sigma',help='Global scaling factor for Gaussian/adaptive Gaussian smearing. The default is determined procedurally, and scaled by this number.',required=.false.,act='store',def='1.0',error=lo_status); if ( lo_status .ne. 0 ) stop 16 | 17 | #define cli_readqmesh call cli%add(switch='--readqmesh',help='Read the q-point mesh from file. To generate a q-mesh file, see the genkpoints utility.',required=.false.,act='store_true',def='.false.',error=lo_status); if ( lo_status .ne. 0 ) stop 18 | 19 | #define cli_manpage call cli%add(switch='--manpage',hidden=.true.,help='',required=.false.,act='store_true',def='.false.',error=lo_status); if ( lo_status .ne. 0 ) stop 20 | 21 | #define cli_verbose call cli%add(switch='--verbose',hidden=.true.,help='',required=.false.,act='store_true',def='.false.',error=lo_status); if ( lo_status .ne. 0 ) stop 22 | 23 | #define cli_readiso call cli%add(switch='--readiso',help='Read the isotope distribution from file',required=.false.,act='store_true',def='.false.',error=lo_status); if ( lo_status .ne. 0 ) stop 24 | 25 | #define cli_no_isotope_scattering call cli%add(switch='--no_isotope_scattering',help='Switch off isotope (mass disorder) scattering',required=.false.,act='store_true',def='.false.',error=lo_status); if ( lo_status .ne. 0 ) stop 26 | 27 | #define cli_temperature call cli%add(switch='--temperature',help='Temperature used in the occupation numbers. Should be the same as the temperature the force constants where determined at.',required=.false.,act='store',def='300',error=lo_status); if ( lo_status .ne. 0 ) stop 28 | 29 | #define cli_support_qpoint_grid call cli%add(switch='--support_qpoint_grid',switch_ab='-sqg',help='Specify a different density for the support q-mesh for the perturbation theory integrals',nargs='3',required=.false.,act='store',def='-1 -1 -1',error=lo_status); if ( lo_status .ne. 0 ) stop 30 | 31 | #define cli_threshold call cli%add(switch='--threshold',help='Consider a Gaussian distribution to be 0 after this many standard deviations.',required=.false.,act='store',def='4.0',error=lo_status); if ( lo_status .ne. 0 ) stop 32 | --------------------------------------------------------------------------------