Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ controllers/options/options_driver.c
controllers/defaults/DEFAULTS_driver.F
services/controllers/SERVICES_setup.F
services/units/UNITS_defaults.F
tests/
12 changes: 12 additions & 0 deletions compile/compile_me.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# License-Identifier: GPL
#
# Copyright (C) 2025 The Yambo Team
#
# Authors (see AUTHORS file for details): AM MN
#
#
# Co-Authors (see AUTHORS file for details): RR
# LetzElPhC ep plugin - yambo build system stub
# Integration handled via SERVICES_LIBS in libraries.mk
#
9 changes: 9 additions & 0 deletions compile/goals.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# License-Identifier: GPL
#
# Copyright (C) 2025 The Yambo Team
#
# Authors (see AUTHORS file for details): AM MN RR
#

.PHONY: lelphc clean_lelphc
14 changes: 14 additions & 0 deletions compile/headers_and_libs.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# License-Identifier: GPL
#
# Copyright (C) 2025 The Yambo Team
#
# Authors (see AUTHORS file for details): RR AM
#
# LetzElPhC ep plugin - extra include paths for the vendored C source.
# C files under plugins/ep/services/<sub>/*.c use relative includes
# like "common/dtypes.h", so the plugin services root must be on the
# include path.
#
iheaders += $(IFLAG)$(srcdir)/plugins/ep/services
include_headers += $(IFLAG)$(srcdir)/plugins/ep/services
16 changes: 16 additions & 0 deletions compile/help.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# License-Identifier: GPL
#
# Copyright (C) 2025 The Yambo Team
#
# Authors (see AUTHORS file for details): RR AM
#
# Help blurb for the ep (LetzElPhC) plugin, called from
# compile/global/functions/help.mk when plugins/ep.pulled is present.
#
define ep_help
$(ECHO) " ep plugin = LetzElPhC electron-phonon coupling plugin";\
$(ECHO) " Trigger: yambo -collisions ep";\
$(ECHO) " Source: plugins/ep/services/, integration: packages/el-ph/";\
$(ECHO)
endef
17 changes: 17 additions & 0 deletions compile/targets.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# License-Identifier: GPL
#
# Copyright (C) 2025 The Yambo Team
#
# Authors (see AUTHORS file for details): AM MN RR
#
# Build the standalone lelphc binary from LetzElPhC C source.
# Requires yambo to have been configured first (config/setup must exist).
# Usage: make lelphc -> builds plugins/ep/services/lelphc
# make clean_lelphc -> cleans the standalone build

lelphc:
$(MAKE) -C $(srcdir)/plugins/ep/services

clean_lelphc:
-$(MAKE) -C $(srcdir)/plugins/ep/services clean
94 changes: 49 additions & 45 deletions services/Makefile
Original file line number Diff line number Diff line change
@@ -1,45 +1,49 @@
include make.inc

TARGET := lelphc

#### make start here

SUBDIR = nonloc io/ezxml parser/inih io \
io/qe common dvloc elph wfc \
symmetries fft common/cwalk \
preprocessor interpolation \
common/ELPH_hash_map phonon \
common/kdtree parser

.SUFFIXES :

INCS = $(wildcard *.h $(foreach fd, $(SUBDIR), $(fd)/*.h))
SRCS = $(wildcard *.c $(foreach fd, $(SUBDIR), $(fd)/*.c))
OBJS = $(addprefix ./, $(SRCS:c=o))

INC_DIRS += -I. $(FFTW_INC) $(NETCDF_INC)
LIBS += $(FFTW3_LIB) $(BLAS_LIB) $(NETCDF_LIB) $(HDF5_LIB) -lm


PHONY := $(TARGET)
$(TARGET): $(OBJS)
$(CC) -o ./$@ $(OBJS) $(LIBS) $(LD_FLAGS)

%.o: %.c $(INCS) make.inc
$(CC) $(CFLAGS) -c $< $(INC_DIRS) $(OPENMP_FLAGS) -o $@


PHONY += clean
clean:
rm ./$(TARGET) $(OBJS)

PHONY += echoes
echoes:
@echo "INC files: $(INCS)"
@echo "SRC files: $(SRCS)"
@echo "OBJ files: $(OBJS)"
@echo "LIB files: $(LIBS)"
@echo "INC DIR: $(INC_DIRS)"


.PHONY = $(PHONY)
#
# License-Identifier: GPL
#
# Copyright (C) 2016 The Yambo Team
#
# Authors (see AUTHORS file for details): HM
#
# VARIABLES (static and dynamical)
#
include dyn_variables.mk
include $(compdir)/compile/local/static_variables.mk
include $(compdir)/compile/local/defs.mk
include $(compdir)/compile/defs.mk
#
# SETUP
#
include $(compdir)/config/setup
#
# Module dependencies
#
-include local_modules.dep
#
# Include directories (headers)
#
include $(compdir)/compile/headers.mk
#
# Libraries
#
include $(compdir)/compile/libraries.mk
ifneq "$(wildcard $(compdir)/plugins/plugins.pulled)" ""
include $(compdir)/plugins/*/compile/headers_and_libs.mk
endif
#
# OBJECTS
#
include objects.mk
#
# OPERATIONS
#
include $(compdir)/compile/local/operations.mk
#
# RULES
#
include $(compdir)/compile/local/rules.mk
#
# FUNCTIONS
#
include $(compdir)/compile/local/functions.mk
#
131 changes: 131 additions & 0 deletions services/compute_dmats.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
#include <netcdf.h>
#include <netcdf_par.h>
#include <stdio.h>
#include <stdlib.h>

#include "common/dtypes.h"
#include "common/error.h"
#include "common/parallel.h"
#include "common/progess_bar.h"
#include "elph.h"
#include "elphC.h"
#include "io/io.h"
#include "symmetries/symmetries.h"

/*
* This function contain the wrapper functions to compute and
* write or read dmat functions to file)
*/

void compute_and_write_dmats(const char* file_name, const struct WFC* wfcs,
const struct Lattice* lattice,
const ND_int nph_sym,
const struct symmetry* sym_data,
const struct ELPH_MPI_Comms* Comm)
{
ND_int nk_totalBZ = lattice->nkpts_BZ;
ELPH_cmplx* Dkmn_rep_ptr = NULL;

int ncid, varid, nc_err;

size_t startp[6] = {0, 0, 0, 0, 0, 0};
size_t countp[6] = {1, 1, lattice->nspin, lattice->nbnds, lattice->nbnds,
2};

ND_int nk_chunk_size = NC4_DEFAULT_CHUCK_KB * 1024; // now this is in bytes
// scale with complex number size to get the number of elements
nk_chunk_size /=
(sizeof(ELPH_cmplx) * lattice->nspin * lattice->nbnds * lattice->nbnds);
// chuck the varaible elph_mat with atmost default size
if (nk_chunk_size == 0)
{
nk_chunk_size = 1;
}
else if (nk_chunk_size > nk_totalBZ)
{
nk_chunk_size = nk_totalBZ;
}

if (Comm->commK_rank == 0)
{
// we overwrite any existing file
if ((nc_err = nc_create_par(file_name, NC_NETCDF4 | NC_CLOBBER,
Comm->commR, MPI_INFO_NULL, &ncid)))
{
fprintf(stderr, "Error creating Dmat file");
ERR(nc_err);
}
// set no fill mode (to avoid writting twice)
if ((nc_err = ncsetfill(ncid, NC_NOFILL)))
{
fprintf(stderr, "Error setting nc_fill to dmat file.");
ERR(nc_err);
}

def_ncVar(ncid, &varid, 6, ELPH_NC4_IO_FLOAT,
(ND_int[]){nph_sym, nk_totalBZ, lattice->nspin,
lattice->nbnds, lattice->nbnds, 2},
"Dmats",
(char*[]){"nsym_ph", "nkpts", "nspin", "Rk_band", "k_band",
"re_im"},
(size_t[]){1, nk_chunk_size, lattice->nspin, lattice->nbnds,
lattice->nbnds, 2});

// Make the access INDEPENDENT as not all can call the put_var function
// simultaneously
if ((nc_err = nc_var_par_access(ncid, varid, NC_INDEPENDENT)))
{
ERR(nc_err);
}

Dkmn_rep_ptr = calloc(lattice->nspin * lattice->nbnds * lattice->nbnds,
sizeof(ELPH_cmplx));
CHECK_ALLOC(Dkmn_rep_ptr);
}

// for computation of Dmats, we use all the nodes
// ("nsym", "nk", "nspin", "nbndb", "nbnda")
ND_int dmat_shift;
ND_int ndmats =
distribute_to_grps(nph_sym * nk_totalBZ, Comm->nqpools * Comm->nkpools,
Comm->commW_rank / Comm->commK_size, &dmat_shift);

// start the progress bar for dmats
struct progress_bar pbar[1];
start_progressbar(pbar, Comm->commW_rank, ndmats);

for (ND_int idmat = 0; idmat < ndmats; ++idmat)
{
ND_int isym = (idmat + dmat_shift) / nk_totalBZ;
ND_int ikBZ = (idmat + dmat_shift) % nk_totalBZ;

startp[0] = isym;
startp[1] = ikBZ;

// compute the dmats
electronic_reps(wfcs, lattice, sym_data[isym].Rmat, sym_data[isym].tau,
sym_data[isym].time_rev, ikBZ, Dkmn_rep_ptr, Comm);

if (Comm->commK_rank == 0)
{
// write data to file
if ((nc_err =
nc_put_vara(ncid, varid, startp, countp, Dkmn_rep_ptr)))
{
ERR(nc_err);
}
}

// update the progress bar
print_progressbar(pbar);
}
if (Comm->commK_rank == 0)
{
free(Dkmn_rep_ptr);

if ((nc_err = nc_close(ncid)))
{
ERR(nc_err);
}
}
}
Loading