Unverified Commit 7de4655e authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

simplify output in KSPACE package

parent b1d4ca2b
Loading
Loading
Loading
Loading
+14 −26
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include "ewald.h"
#include <mpi.h>
#include <cmath>
#include <string>
#include "atom.h"
#include "comm.h"
#include "force.h"
@@ -29,6 +30,8 @@
#include "math_const.h"
#include "memory.h"
#include "error.h"
#include "utils.h"
#include "fmt/format.h"

using namespace LAMMPS_NS;
using namespace MathConst;
@@ -88,10 +91,7 @@ Ewald::~Ewald()

void Ewald::init()
{
  if (comm->me == 0) {
    if (screen) fprintf(screen,"Ewald initialization ...\n");
    if (logfile) fprintf(logfile,"Ewald initialization ...\n");
  }
  if (comm->me == 0) utils::logmesg(lmp,"Ewald initialization ...\n");

  // error check

@@ -185,28 +185,16 @@ void Ewald::init()
  // stats

  if (comm->me == 0) {
    if (screen) {
      fprintf(screen,"  G vector (1/distance) = %g\n",g_ewald);
      fprintf(screen,"  estimated absolute RMS force accuracy = %g\n",
              estimated_accuracy);
      fprintf(screen,"  estimated relative force accuracy = %g\n",
              estimated_accuracy/two_charge_force);
      fprintf(screen,"  KSpace vectors: actual max1d max3d = %d %d %d\n",
              kcount,kmax,kmax3d);
      fprintf(screen,"                  kxmax kymax kzmax  = %d %d %d\n",
              kxmax,kymax,kzmax);
    }
    if (logfile) {
      fprintf(logfile,"  G vector (1/distance) = %g\n",g_ewald);
      fprintf(logfile,"  estimated absolute RMS force accuracy = %g\n",
    std::string mesg = fmt::format("  G vector (1/distance) = {}\n",g_ewald);
    mesg += fmt::format("  estimated absolute RMS force accuracy = {}\n",
                       estimated_accuracy);
      fprintf(logfile,"  estimated relative force accuracy = %g\n",
    mesg += fmt::format("  estimated relative force accuracy = {}\n",
                       estimated_accuracy/two_charge_force);
      fprintf(logfile,"  KSpace vectors: actual max1d max3d = %d %d %d\n",
    mesg += fmt::format("  KSpace vectors: actual max1d max3d = {} {} {}\n",
                        kcount,kmax,kmax3d);
      fprintf(logfile,"                  kxmax kymax kzmax  = %d %d %d\n",
    mesg += fmt::format("                  kxmax kymax kzmax  = {} {} {}\n",
                        kxmax,kymax,kzmax);
    }
    utils::logmesg(lmp,mesg);
  }
}

+14 −26
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#include "ewald_dipole.h"
#include <mpi.h>
#include <cstring>
#include <string>
#include <cmath>
#include "atom.h"
#include "comm.h"
@@ -29,6 +30,8 @@
#include "memory.h"
#include "error.h"
#include "update.h"
#include "utils.h"
#include "fmt/format.h"

using namespace LAMMPS_NS;
using namespace MathConst;
@@ -63,10 +66,7 @@ EwaldDipole::~EwaldDipole()

void EwaldDipole::init()
{
  if (comm->me == 0) {
    if (screen) fprintf(screen,"EwaldDipole initialization ...\n");
    if (logfile) fprintf(logfile,"EwaldDipole initialization ...\n");
  }
  if (comm->me == 0) utils::logmesg(lmp,"EwaldDipole initialization ...\n");

  // error check

@@ -192,28 +192,16 @@ void EwaldDipole::init()
  // stats

  if (comm->me == 0) {
    if (screen) {
      fprintf(screen,"  G vector (1/distance) = %g\n",g_ewald);
      fprintf(screen,"  estimated absolute RMS force accuracy = %g\n",
              estimated_accuracy);
      fprintf(screen,"  estimated relative force accuracy = %g\n",
              estimated_accuracy/two_charge_force);
      fprintf(screen,"  KSpace vectors: actual max1d max3d = %d %d %d\n",
              kcount,kmax,kmax3d);
      fprintf(screen,"                  kxmax kymax kzmax  = %d %d %d\n",
              kxmax,kymax,kzmax);
    }
    if (logfile) {
      fprintf(logfile,"  G vector (1/distance) = %g\n",g_ewald);
      fprintf(logfile,"  estimated absolute RMS force accuracy = %g\n",
    std::string mesg = fmt::format("  G vector (1/distance) = {}\n",g_ewald);
    mesg += fmt::format("  estimated absolute RMS force accuracy = {}\n",
                       estimated_accuracy);
      fprintf(logfile,"  estimated relative force accuracy = %g\n",
    mesg += fmt::format("  estimated relative force accuracy = {}\n",
                       estimated_accuracy/two_charge_force);
      fprintf(logfile,"  KSpace vectors: actual max1d max3d = %d %d %d\n",
    mesg += fmt::format("  KSpace vectors: actual max1d max3d = {} {} {}\n",
                        kcount,kmax,kmax3d);
      fprintf(logfile,"                  kxmax kymax kzmax  = %d %d %d\n",
    mesg += fmt::format("                  kxmax kymax kzmax  = {} {} {}\n",
                        kxmax,kymax,kzmax);
    }
    utils::logmesg(lmp,mesg);
  }
}

+14 −26
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#include "ewald_dipole_spin.h"
#include <mpi.h>
#include <cstring>
#include <string>
#include <cmath>
#include "atom.h"
#include "comm.h"
@@ -28,6 +29,8 @@
#include "memory.h"
#include "error.h"
#include "update.h"
#include "utils.h"
#include "fmt/format.h"

using namespace LAMMPS_NS;
using namespace MathConst;
@@ -61,10 +64,7 @@ EwaldDipoleSpin::~EwaldDipoleSpin() {}

void EwaldDipoleSpin::init()
{
  if (comm->me == 0) {
    if (screen) fprintf(screen,"EwaldDipoleSpin initialization ...\n");
    if (logfile) fprintf(logfile,"EwaldDipoleSpin initialization ...\n");
  }
  if (comm->me == 0) utils::logmesg(lmp,"EwaldDipoleSpin initialization ...\n");

  // error check

@@ -182,28 +182,16 @@ void EwaldDipoleSpin::init()
  // stats

  if (comm->me == 0) {
    if (screen) {
      fprintf(screen,"  G vector (1/distance) = %g\n",g_ewald);
      fprintf(screen,"  estimated absolute RMS force accuracy = %g\n",
              estimated_accuracy);
      fprintf(screen,"  estimated relative force accuracy = %g\n",
              estimated_accuracy/two_charge_force);
      fprintf(screen,"  KSpace vectors: actual max1d max3d = %d %d %d\n",
              kcount,kmax,kmax3d);
      fprintf(screen,"                  kxmax kymax kzmax  = %d %d %d\n",
              kxmax,kymax,kzmax);
    }
    if (logfile) {
      fprintf(logfile,"  G vector (1/distance) = %g\n",g_ewald);
      fprintf(logfile,"  estimated absolute RMS force accuracy = %g\n",
    std::string mesg = fmt::format("  G vector (1/distance) = {}\n",g_ewald);
    mesg += fmt::format("  estimated absolute RMS force accuracy = {}\n",
                       estimated_accuracy);
      fprintf(logfile,"  estimated relative force accuracy = %g\n",
    mesg += fmt::format("  estimated relative force accuracy = {}\n",
                       estimated_accuracy/two_charge_force);
      fprintf(logfile,"  KSpace vectors: actual max1d max3d = %d %d %d\n",
    mesg += fmt::format("  KSpace vectors: actual max1d max3d = {} {} {}\n",
                        kcount,kmax,kmax3d);
      fprintf(logfile,"                  kxmax kymax kzmax  = %d %d %d\n",
    mesg += fmt::format("                  kxmax kymax kzmax  = {} {} {}\n",
                        kxmax,kymax,kzmax);
    }
    utils::logmesg(lmp,mesg);
  }
}

+12 −17
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#include "ewald_disp.h"
#include <mpi.h>
#include <cstring>
#include <string>
#include <cmath>
#include "math_vector.h"
#include "math_const.h"
@@ -30,6 +31,8 @@
#include "memory.h"
#include "error.h"
#include "update.h"
#include "utils.h"
#include "fmt/format.h"

using namespace LAMMPS_NS;
using namespace MathConst;
@@ -89,10 +92,7 @@ void EwaldDisp::init()
  nbox = -1;
  bytes = 0.0;

  if (!comm->me) {
    if (screen) fprintf(screen,"EwaldDisp initialization ...\n");
    if (logfile) fprintf(logfile,"EwaldDisp initialization ...\n");
  }
  if (!comm->me) utils::logmesg(lmp,"EwaldDisp initialization ...\n");

  triclinic_check();
  if (domain->dimension == 2)
@@ -169,11 +169,9 @@ void EwaldDisp::init()
  if (qsqsum == 0.0 && bsbsum == 0.0 && M2 == 0.0)
      error->all(FLERR,"Cannot use Ewald/disp solver "
                 "on system with no charge, dipole, or LJ particles");
  if (fabs(qsum) > SMALL && comm->me == 0) {
      char str[128];
      sprintf(str,"System is not charge neutral, net charge = %g",qsum);
      error->warning(FLERR,str);
  }
  if (fabs(qsum) > SMALL && comm->me == 0)
    error->warning(FLERR,fmt::format("System is not charge neutral, "
                                     "net charge = {}",qsum));

  if (!function[1] && !function[2]) dispersionflag = 0;
  if (!function[3]) dipoleflag = 0;
@@ -229,10 +227,9 @@ void EwaldDisp::init()
    }
  }

  if (!comm->me) {
      if (screen) fprintf(screen, "  G vector = %g,   accuracy = %g\n", g_ewald,accuracy);
      if (logfile) fprintf(logfile, "  G vector = %g   accuracy = %g\n", g_ewald,accuracy);
  }
  if (!comm->me)
    utils::logmesg(lmp,fmt::format("  G vector = {},   accuracy = {}\n",
                                   g_ewald,accuracy));

  g_ewald_6 = g_ewald;
  deallocate_peratom();
@@ -294,10 +291,8 @@ void EwaldDisp::setup()

  if (!(first_output||comm->me)) {
    first_output = 1;
    if (screen) fprintf(screen,
               "  vectors: nbox = %d, nkvec = %d\n", nbox, nkvec);
    if (logfile) fprintf(logfile,
        "  vectors: nbox = %d, nkvec = %d\n", nbox, nkvec);
    utils::logmesg(lmp,fmt::format("  vectors: nbox = {}, nkvec = {}\n",
                                   nbox, nkvec));
  }
}

+20 −13
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@
#include <cmath>
#include <cstring>
#include <limits>
#include <string>
#include "comm.h"
#include "update.h"
#include "force.h"
#include "kspace.h"
@@ -29,6 +31,8 @@
#include "neighbor.h"
#include "modify.h"
#include "compute.h"
#include "utils.h"
#include "fmt/format.h"

#define SWAP(a,b) {temp=(a);(a)=(b);(b)=temp;}
#define SIGN(a,b) ((b) >= 0.0 ? fabs(a) : -fabs(a))
@@ -146,10 +150,11 @@ void FixTuneKspace::pre_exchange()
    update_kspace_style(new_kspace_style,new_acc_str);
  } else if (niter == 4) {
    store_old_kspace_settings();    
    if (screen) fprintf(screen,"ewald_time = %g\npppm_time = %g\nmsm_time = %g",
                        ewald_time, pppm_time, msm_time);
    if (logfile) fprintf(logfile,"ewald_time = %g\npppm_time = %g\nmsm_time = %g",
                         ewald_time, pppm_time, msm_time);
    if (comm->me == 0)
      utils::logmesg(lmp,fmt::format("ewald_time = {}\n"
                                     "pppm_time = {}\n"
                                     "msm_time = {}\n",
                                     ewald_time, pppm_time, msm_time));
    // switch to fastest one
    strcpy(new_kspace_style,"ewald");
    snprintf(new_pair_style,64,"%s/long",base_pair_style);
@@ -240,8 +245,8 @@ void FixTuneKspace::update_pair_style(char *new_pair_style,
  p_pair_settings_file = tmpfile();
  force->pair->write_restart(p_pair_settings_file);
  rewind(p_pair_settings_file);
  if (screen) fprintf(screen,"Creating new pair style: %s\n",new_pair_style);
  if (logfile) fprintf(logfile,"Creating new pair style: %s\n",new_pair_style);
  if (comm->me == 0)
    utils::logmesg(lmp,fmt::format("Creating new pair style: {}\n",new_pair_style));
  // delete old pair style and create new one
  force->create_pair(new_pair_style,1);

@@ -250,8 +255,9 @@ void FixTuneKspace::update_pair_style(char *new_pair_style,

  double *pcutoff = (double *) force->pair->extract("cut_coul",itmp);
  double current_cutoff = *pcutoff;
  if (screen) fprintf(screen,"Coulomb cutoff for real space: %g\n", current_cutoff);
  if (logfile) fprintf(logfile,"Coulomb cutoff for real space: %g\n", current_cutoff);
  if (comm->me == 0)
    utils::logmesg(lmp,fmt::format("Coulomb cutoff for real space: {}\n",
                                   current_cutoff));

  // close temporary file
  fclose(p_pair_settings_file);
@@ -319,8 +325,9 @@ void FixTuneKspace::adjust_rcut(double time)
  int itmp;
  double *p_cutoff = (double *) force->pair->extract("cut_coul",itmp);
  double current_cutoff = *p_cutoff;
  if (screen) fprintf(screen,"Old Coulomb cutoff for real space: %g\n",current_cutoff);
  if (logfile) fprintf(logfile,"Old Coulomb cutoff for real space: %g\n",current_cutoff);
  if (comm->me == 0)
    utils::logmesg(lmp,fmt::format("Old Coulomb cutoff for real space: {}\n",
                                   current_cutoff));

  // use Brent's method from Numerical Recipes to find optimal real space cutoff

@@ -390,8 +397,8 @@ void FixTuneKspace::adjust_rcut(double time)
  // report the new cutoff
  double *new_cutoff = (double *) force->pair->extract("cut_coul",itmp);
  current_cutoff = *new_cutoff;
  if (screen) fprintf(screen,"Adjusted Coulomb cutoff for real space: %g\n", current_cutoff);
  if (logfile) fprintf(logfile,"Adjusted Coulomb cutoff for real space: %g\n", current_cutoff);
  if (comm->me == 0)
    utils::logmesg(lmp,fmt::format("Adjusted Coulomb cutoff for real space: {}\n", current_cutoff));

  store_old_kspace_settings();
  update_pair_style(new_pair_style,pair_cut_coul);
Loading