From f2b6027b029de789db31b443e3e7db5c8529f1e5 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Tue, 30 Aug 2022 16:00:13 -0600 Subject: [PATCH] disable certain options in fix ttm/grid for distributed grids --- doc/src/fix_ave_grid.rst | 3 +- doc/src/fix_ttm.rst | 64 +++++++++++++++--------- examples/ttm/in.ttm.grid | 5 ++ src/EXTRA-FIX/fix_ttm_grid.cpp | 90 ++-------------------------------- src/EXTRA-FIX/fix_ttm_grid.h | 1 - 5 files changed, 52 insertions(+), 111 deletions(-) diff --git a/doc/src/fix_ave_grid.rst b/doc/src/fix_ave_grid.rst index 7e98f3d619..81cdc06921 100644 --- a/doc/src/fix_ave_grid.rst +++ b/doc/src/fix_ave_grid.rst @@ -479,4 +479,5 @@ Related commands Default """"""" -The option defaults are norm = all, ave = one, and bias = none. +The option defaults are discard = yes, norm = all, ave = one, and bias += none. diff --git a/doc/src/fix_ttm.rst b/doc/src/fix_ttm.rst index 5ecb2f30f4..73bd70f76f 100644 --- a/doc/src/fix_ttm.rst +++ b/doc/src/fix_ttm.rst @@ -183,19 +183,22 @@ embedded within a larger continuum representation of the electronic subsystem. The *set* keyword specifies a *Tinit* temperature value to initialize -the value stored on all grid points. +the value stored on all grid points. By default the temperatures +are all zero when the grid is created. The *infile* keyword specifies an input file of electronic temperatures -for each grid point to be read in to initialize the grid. By default -the temperatures are all zero when the grid is created. The input file -is a text file which may have comments starting with the '#' character. -Each line contains four numeric columns: ix,iy,iz,Temperature. Empty -or comment-only lines will be ignored. The -number of lines must be equal to the number of user-specified grid -points (Nx by Ny by Nz). The ix,iy,iz are grid point indices ranging -from 0 to nxnodes-1 inclusive in each dimension. The lines can appear -in any order. For example, the initial electronic temperatures on a 1 -by 2 by 3 grid could be specified in the file as follows: +for each grid point to be read in to initialize the grid, as an alternative +to using the *set* keyword. + +The input file is a text file which may have comments starting with +the '#' character. Each line contains four numeric columns: +ix,iy,iz,Temperature. Empty or comment-only lines will be +ignored. The number of lines must be equal to the number of +user-specified grid points (Nx by Ny by Nz). The ix,iy,iz are grid +point indices ranging from 0 to nxnodes-1 inclusive in each dimension. +The lines can appear in any order. For example, the initial +electronic temperatures on a 1 by 2 by 3 grid could be specified in +the file as follows: .. parsed-literal:: @@ -229,11 +232,20 @@ the same as the input temperature file. It will contain a comment in the first line reporting the date the file was created, the LAMMPS units setting in use, grid size and the current timestep. -Note that the atomic temperature for atoms in each grid cell can also -be computed and output by the :doc:`fix ave/chunk ` -command using the :doc:`compute chunk/atom ` -command to create a 3d array of chunks consistent with the grid used -by this fix. +.. note:: + + The fix ttm/grid command does not support the *outfile* keyword. + Instead you can use the :doc:`dump grid ` command to output + the electronic temperature on the distributed grid to a dump file. + +For the fix ttm and fix ttm/mod commands, the corresponding atomic +temperature for atoms in each grid cell can be computed and output by +the :doc:`fix ave/chunk ` command using the +:doc:`compute chunk/atom ` command to create a 3d +array of chunks consistent with the grid used by this fix. For the +fix ttm/grid command the same thing can be done using the :doc:`fix +ave/grid ` command and its per-grid values can be output +via the :doc:`dump grid ` command. ---------- @@ -339,13 +351,16 @@ ignored. The lines with the even numbers are treated as follows: Restart, fix_modify, output, run start/stop, minimize info """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" -These fixes write the state of the electronic subsystem and the energy -exchange between the subsystems to :doc:`binary restart files -`. See the :doc:`read_restart ` command for -info on how to re-specify a fix in an input script that reads a -restart file, so that the operation of the fix continues in an -uninterrupted fashion. Note that the restart script must define the -same size grid as the original script. +The fix ttm and fix ttm/mod commands write the state of the electronic +subsystem and the energy exchange between the subsystems to +:doc:`binary restart files `. The fix ttm/grid command does +not yet support writing of its distributed grid to a restart file. + +See the :doc:`read_restart ` command for info on how to +re-specify a fix in an input script that reads a restart file, so that +the operation of the fix continues in an uninterrupted fashion. Note +that the restart script must define the same size grid as the original +script. Because the state of the random number generator is not saved in the restart files, this means you cannot do "exact" restarts with this @@ -373,7 +388,8 @@ The vector values calculated are "extensive". Th fix ttm/grid command also calculates a per-grid vector which store the electron temperature for each grid cell in temperature :doc:`units -`. The length of the vector (distributed across all +`. which can be accessed by various :doc:`output commands +`. The length of the vector (distributed across all processors) is Nx * Ny * Nz. For access by other commands, the name of the grid produced by fix ttm/grid is "grid". The name of its data is "data". diff --git a/examples/ttm/in.ttm.grid b/examples/ttm/in.ttm.grid index 2e3c622823..044778c62f 100644 --- a/examples/ttm/in.ttm.grid +++ b/examples/ttm/in.ttm.grid @@ -40,4 +40,9 @@ thermo 100 thermo_style custom step temp etotal f_twotemp[1] f_twotemp[2] thermo_modify format float "%20.16g" +compute 10 all property/grid 5 5 5 id xc yc zc +fix ave all ave/grid 100 5 500 5 5 5 f_twotemp:grid:data +dump ave all grid 500 tmp.dump.ave & + c_10:grid:data[*] f_ave:grid:data + run 1000 diff --git a/src/EXTRA-FIX/fix_ttm_grid.cpp b/src/EXTRA-FIX/fix_ttm_grid.cpp index e5af0a8991..b472237df8 100644 --- a/src/EXTRA-FIX/fix_ttm_grid.cpp +++ b/src/EXTRA-FIX/fix_ttm_grid.cpp @@ -57,11 +57,8 @@ FixTTMGrid::FixTTMGrid(LAMMPS *lmp, int narg, char **arg) : pergrid_flag = 1; pergrid_freq = 1; - /* - NOTE: uncomment this when ready to release if (outfile) error->all(FLERR,"Fix ttm/grid does not support outfile option - " - "use dump grid instead"); - */ + "use dump grid command instead"); skin_original = neighbor->skin; } @@ -364,30 +361,6 @@ void FixTTMGrid::read_electron_temperatures(const std::string &filename) memory->destroy3d_offset(T_initial_set, nzlo_in, nylo_in, nxlo_in); } -/* ---------------------------------------------------------------------- - write out current electron temperatures to user-specified file - only written by proc 0 - NOTE: remove this function when ready to release -------------------------------------------------------------------------- */ - -void FixTTMGrid::write_electron_temperatures(const std::string &filename) -{ - if (comm->me == 0) { - FPout = fopen(filename.c_str(), "w"); - if (!FPout) error->one(FLERR, "Fix ttm/grid could not open output file"); - - fmt::print(FPout, - "# DATE: {} UNITS: {} COMMENT: Electron temperature " - "{}x{}x{} grid at step {}. Created by fix {}\n", - utils::current_date(), update->unit_style, nxgrid, nygrid, nzgrid, update->ntimestep, - style); - } - - grid->gather(Grid3d::FIX, this, 1, sizeof(double), 1, nullptr, MPI_DOUBLE); - - if (comm->me == 0) fclose(FPout); -} - /* ---------------------------------------------------------------------- subset of grid assigned to each proc may have changed called by load balancer when proc subdomains are adjusted @@ -500,27 +473,8 @@ void FixTTMGrid::deallocate_grid() void FixTTMGrid::write_restart(FILE *fp) { - int rsize = nxgrid * nygrid * nzgrid + 4; - double *rlist; - memory->create(rlist, rsize, "ttm/grid:rlist"); - - int n = 0; - rlist[n++] = nxgrid; - rlist[n++] = nygrid; - rlist[n++] = nzgrid; - rlist[n++] = seed; - - // gather rest of rlist on proc 0 as global grid values - - //grid->gather(Grid3d::FIX, this, 1, sizeof(double), 0, &rlist[4], MPI_DOUBLE); - - if (comm->me == 0) { - int size = rsize * sizeof(double); - fwrite(&size, sizeof(int), 1, fp); - fwrite(rlist, sizeof(double), rsize, fp); - } - - memory->destroy(rlist); + error->all(FLERR,"Fix ttm/grid command does not yet support " + "writing a distributed grid to a restart file"); } /* ---------------------------------------------------------------------- @@ -529,42 +483,8 @@ void FixTTMGrid::write_restart(FILE *fp) void FixTTMGrid::restart(char *buf) { - int ix, iy, iz; - - int n = 0; - auto rlist = (double *) buf; - - // check that restart grid size is same as current grid size - - int nxgrid_old = static_cast(rlist[n++]); - int nygrid_old = static_cast(rlist[n++]); - int nzgrid_old = static_cast(rlist[n++]); - - if (nxgrid_old != nxgrid || nygrid_old != nygrid || nzgrid_old != nzgrid) - error->all(FLERR, "Must restart fix ttm/grid with same grid size"); - - // change RN seed from initial seed, to avoid same Langevin factors - // just increment by 1, since for RanMars that is a new RN stream - - seed = static_cast(rlist[n++]) + 1; - delete random; - random = new RanMars(lmp, seed + comm->me); - - // extract this proc's local grid values from global grid in rlist - - int iglobal; - - for (iz = nzlo_in; iz <= nzhi_in; iz++) - for (iy = nylo_in; iy <= nyhi_in; iy++) - for (ix = nxlo_in; ix <= nxhi_in; ix++) { - iglobal = nygrid * nxgrid * iz + nxgrid * iy + ix; - T_electron[iz][iy][ix] = rlist[n + iglobal]; - } - - // communicate new T_electron values to ghost grid points - - grid->forward_comm(Grid3d::FIX, this, 1, sizeof(double), 0, - grid_buf1, grid_buf2, MPI_DOUBLE); + error->all(FLERR,"Fix ttm/grid command does not yet support " + "reading a distributed grid from a restart file"); } /* ---------------------------------------------------------------------- diff --git a/src/EXTRA-FIX/fix_ttm_grid.h b/src/EXTRA-FIX/fix_ttm_grid.h index 0e77232337..28a975a0bd 100644 --- a/src/EXTRA-FIX/fix_ttm_grid.h +++ b/src/EXTRA-FIX/fix_ttm_grid.h @@ -70,7 +70,6 @@ class FixTTMGrid : public FixTTM { void allocate_grid() override; void deallocate_grid() override; void read_electron_temperatures(const std::string &) override; - void write_electron_temperatures(const std::string &) override; }; } // namespace LAMMPS_NS