From 66273325687348ff57b435e33e9428c6cb6050be Mon Sep 17 00:00:00 2001
From: sjplimp <sjplimp@f3b2605a-c512-4ea7-a41b-209d697bcdaa>
Date: Wed, 27 Jun 2007 20:57:28 +0000
Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@690
 f3b2605a-c512-4ea7-a41b-209d697bcdaa

---
 src/change_box.cpp      | 63 +++++++++++++++++++++++++++++++++++++++++
 src/change_box.h        | 29 +++++++++++++++++++
 src/fix.cpp             |  2 +-
 src/fix.h               |  2 +-
 src/fix_ave_spatial.cpp |  2 +-
 src/fix_deform.cpp      |  2 +-
 src/style.h             |  4 +--
 7 files changed, 98 insertions(+), 6 deletions(-)
 create mode 100644 src/change_box.cpp
 create mode 100644 src/change_box.h

diff --git a/src/change_box.cpp b/src/change_box.cpp
new file mode 100644
index 0000000000..471b167914
--- /dev/null
+++ b/src/change_box.cpp
@@ -0,0 +1,63 @@
+/* ----------------------------------------------------------------------
+   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
+
+   Copyright (2003) Sandia Corporation.  Under the terms of Contract
+   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
+   certain rights in this software.  This software is distributed under 
+   the GNU General Public License.
+
+   See the README file in the top-level LAMMPS directory.
+------------------------------------------------------------------------- */
+
+#include "string"
+#include "change_box.h"
+#include "domain.h"
+#include "modify.h"
+#include "fix.h"
+#include "output.h"
+#include "error.h"
+
+using namespace LAMMPS_NS;
+
+enum{ORTHO,TRICLINIC};
+
+/* ---------------------------------------------------------------------- */
+
+ChangeBox::ChangeBox(LAMMPS *lmp) : Pointers(lmp) {}
+
+/* ---------------------------------------------------------------------- */
+
+void ChangeBox::command(int narg, char **arg)
+{
+  if (domain->box_exist == 0) 
+    error->all("Change_box command before simulation box is defined");
+  if (narg != 1) error->all("Illegal change_box command");
+
+  int style;
+  if (strcmp(arg[0],"ortho") == 0) style = ORTHO;
+  else if (strcmp(arg[0],"triclinic") == 0) style = TRICLINIC;
+
+  if (style == ORTHO && domain->triclinic == 0)
+    error->all("Change_box operation is invalid");
+  if (style == TRICLINIC && domain->triclinic == 1)
+    error->all("Change_box operation is invalid");
+  if (style == ORTHO && 
+      (domain->xy != 0.0 || domain->yz != 0.0 || domain->xz != 0.0))
+      error->all("Cannot change box to orthogonal when tilt is non-zero");
+
+  if (output->ndump)
+    error->all("Cannot change box with dumps defined");
+  for (int i = 0; i < modify->nfix; i++)
+    if (modify->fix[i]->no_change_box)
+      error->all("Cannot change box with certain fixes defined");
+
+  if (style == ORTHO) domain->triclinic = 0;
+  else domain->triclinic = 1;
+  domain->xy = domain->yz = domain->xz = 0.0;
+
+  domain->set_global_box();
+  if (style == TRICLINIC) domain->set_lamda_box();
+  domain->set_local_box();
+}
diff --git a/src/change_box.h b/src/change_box.h
new file mode 100644
index 0000000000..1dcc5d9634
--- /dev/null
+++ b/src/change_box.h
@@ -0,0 +1,29 @@
+/* ----------------------------------------------------------------------
+   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
+
+   Copyright (2003) Sandia Corporation.  Under the terms of Contract
+   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
+   certain rights in this software.  This software is distributed under 
+   the GNU General Public License.
+
+   See the README file in the top-level LAMMPS directory.
+------------------------------------------------------------------------- */
+
+#ifndef CHANGE_BOX_H
+#define CHANGE_BOX_H
+
+#include "pointers.h"
+
+namespace LAMMPS_NS {
+
+class ChangeBox : protected Pointers {
+ public:
+  ChangeBox(class LAMMPS *);
+  void command(int, char **);
+};
+
+}
+
+#endif
diff --git a/src/fix.cpp b/src/fix.cpp
index 4d05902476..1a50c86643 100644
--- a/src/fix.cpp
+++ b/src/fix.cpp
@@ -41,7 +41,7 @@ Fix::Fix(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
   pressure_every = 0;
   rigid_flag = 0;
   virial_flag = 0;
-  no_convert_box = 0;
+  no_change_box = 0;
 
   comm_forward = comm_reverse = 0;
   neigh_half_once = neigh_half_every = 0;
diff --git a/src/fix.h b/src/fix.h
index 475b79afe4..551358dc49 100644
--- a/src/fix.h
+++ b/src/fix.h
@@ -33,7 +33,7 @@ class Fix : protected Pointers {
   int pressure_every;            // how often fix needs virial computed
   int rigid_flag;                // 1 if Fix integrates rigid bodies, 0 if not
   int virial_flag;               // 1 if Fix contributes to virial, 0 if not
-  int no_convert_box;            // 1 if cannot swap ortho <-> triclinic
+  int no_change_box;             // 1 if cannot swap ortho <-> triclinic
 
   int comm_forward;              // size of forward communication (0 if none)
   int comm_reverse;              // size of reverse communication (0 if none)
diff --git a/src/fix_ave_spatial.cpp b/src/fix_ave_spatial.cpp
index d3eeeca4ee..d52e4124e5 100644
--- a/src/fix_ave_spatial.cpp
+++ b/src/fix_ave_spatial.cpp
@@ -42,7 +42,7 @@ FixAveSpatial::FixAveSpatial(LAMMPS *lmp, int narg, char **arg) :
 {
   if (narg < 11) error->all("Illegal fix ave/spatial command");
 
-  no_convert_box = 1;
+  no_change_box = 1;
 
   nevery = atoi(arg[3]);
   nfreq = atoi(arg[4]);
diff --git a/src/fix_deform.cpp b/src/fix_deform.cpp
index 0b41f1b0c1..4ec2510f66 100644
--- a/src/fix_deform.cpp
+++ b/src/fix_deform.cpp
@@ -45,7 +45,7 @@ FixDeform::FixDeform(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
   if (narg < 4) error->all("Illegal fix deform command");
 
   box_change = 1;
-  no_convert_box = 1;
+  no_change_box = 1;
 
   nevery = atoi(arg[3]);
   if (nevery <= 0) error->all("Illegal fix deform command");
diff --git a/src/style.h b/src/style.h
index c751146496..785d68e560 100644
--- a/src/style.h
+++ b/src/style.h
@@ -36,7 +36,7 @@ AtomStyle(hybrid,AtomVecHybrid)
 #endif
 
 #ifdef CommandInclude
-#include "convert_box.h"
+#include "change_box.h"
 #include "create_atoms.h"
 #include "create_box.h"
 #include "delete_atoms.h"
@@ -56,7 +56,7 @@ AtomStyle(hybrid,AtomVecHybrid)
 #endif
 
 #ifdef CommandClass
-CommandStyle(convert_box,ConvertBox)
+CommandStyle(change_box,ChangeBox)
 CommandStyle(create_atoms,CreateAtoms)
 CommandStyle(create_box,CreateBox)
 CommandStyle(delete_atoms,DeleteAtoms)
-- 
GitLab