[tools] Split off g_saxs from g_rdf
authorAlexey Shvetsov <alexxy@omrb.pnpi.spb.ru>
Sat, 13 Oct 2012 05:53:47 +0000 (09:53 +0400)
committerAlexey Shvetsov <alexxy@omrb.pnpi.spb.ru>
Fri, 7 Dec 2012 12:39:00 +0000 (16:39 +0400)
this change needed for the following merge of sans and saxs methods into
one library

Change-Id: I1e154175f3567e3e584a7b3367969c81619c2978
Signed-off-by: Alexey Shvetsov <alexxy@omrb.pnpi.spb.ru>
admin/programs.txt
src/gromacs/legacyheaders/gmx_ana.h
src/tools/CMakeLists.txt
src/tools/g_saxs.c [new file with mode: 0644]
src/tools/gmx_rdf.c
src/tools/gmx_saxs.c [new file with mode: 0644]

index bee575792fffe20763105ac73012e34ee624bc4c..d6b05f0f6ac0087ba1002082df75c4d93198f1cc 100644 (file)
@@ -80,6 +80,7 @@ g_rdf|calculates radial distribution functions
 g_rotacf|calculates the rotational correlation function for molecules
 g_rotmat|plots the rotation matrix for fitting to a reference structure
 g_sans|computes the small angle neutron scattering spectra
+g_saxs|computes the small angle X-Ray scattering spectra
 g_traj|plots x, v, f, box, temperature and rotational energy
 g_vanhove|calculates Van Hove displacement functions
 END
index 8b025f46f8d7b3784b9e4ad7d468e08c5e428a80..d8fc34f1988bf1bffcf0ff0267e83daf155a2215 100644 (file)
@@ -303,6 +303,9 @@ gmx_options(int argc,char *argv[]);
 int
 gmx_sans(int argc,char *argv[]);
 
+int
+gmx_saxs(int argc,char *argv[]);
+
 #ifdef __cplusplus
 }
 #endif
index ab7e69cacdf7956d5d76e2fa95103e10140257f5..2b3cf66350a017d872f5efc1e2e1b452e647e84d 100644 (file)
@@ -31,6 +31,7 @@ add_library(gmxana
             gmx_hydorder.c  gmx_densorder.c powerspect.c    dens_filter.c
             binsearch.c     gmx_dyecoupl.c  gmx_make_edi.c  gmx_sigeps.c
             gmx_do_dssp.c   gmx_anadock.c   gmx_make_ndx.c  gmx_mk_angndx.c
+           gmx_saxs.c
             )
 
 
@@ -55,7 +56,7 @@ set(GMX_TOOLS_PROGRAMS
     g_spol g_spatial g_tcaf g_traj g_tune_pme g_vanhove
     g_velacc g_clustsize g_mdmat g_wham g_sigeps g_bar
     g_pme_error g_rmsdist g_rotmat g_options
-    g_dos    g_hydorder  g_densorder g_dyecoupl g_sans
+    g_dos    g_hydorder  g_densorder g_dyecoupl g_sans  g_saxs
     )
 
 set(GMX_TOOLS_PROGRAMS_NOT_FOR_INSTALLATION
diff --git a/src/tools/g_saxs.c b/src/tools/g_saxs.c
new file mode 100644 (file)
index 0000000..bca93c8
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * 
+ *                This source code is part of
+ * 
+ *                 G   R   O   M   A   C   S
+ * 
+ *          GROningen MAchine for Chemical Simulations
+ * 
+ *                        VERSION 3.2.0
+ * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
+ * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
+ * Copyright (c) 2001-2004, The GROMACS development team,
+ * check out http://www.gromacs.org for more information.
+
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * If you want to redistribute modifications, please consider that
+ * scientific software is very special. Version control is crucial -
+ * bugs must be traceable. We will be happy to consider code for
+ * inclusion in the official distribution, but derived work must not
+ * be called official GROMACS. Details are found in the README & COPYING
+ * files - if they are missing, get the official version at www.gromacs.org.
+ * 
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the papers on the package - you can find them in the top README file.
+ * 
+ * For more info, check our website at http://www.gromacs.org
+ * 
+ * And Hey:
+ * Green Red Orange Magenta Azure Cyan Skyblue
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gmx_ana.h>
+
+
+/* This is just a wrapper binary
+ * The code is in gmx_saxs.c,
+ */
+int
+main(int argc, char *argv[])
+{
+  gmx_saxs(argc,argv);
+  return 0;
+}
+
+
+  
index 4c0b3a7bfd724fae96bb7fe50d6c2d2f215c2d3f..dda9f07ade1c0bfc97a472d9793b1ed28adbe922 100644 (file)
@@ -60,8 +60,6 @@
 #include "matio.h"
 #include "gmx_ana.h"
 #include "names.h"
-#include "sfactor.h"
-
 
 static void check_box_c(matrix box)
 {
@@ -654,15 +652,11 @@ int gmx_rdf(int argc,char *argv[])
     "Note that all atoms in the selected groups are used, also the ones",
     "that don't have Lennard-Jones interactions.[PAR]",
     "Option [TT]-cn[tt] produces the cumulative number RDF,",
-    "i.e. the average number of particles within a distance r.[PAR]",
-    "To bridge the gap between theory and experiment structure factors can",
-    "be computed (option [TT]-sq[tt]). The algorithm uses FFT, the grid",
-    "spacing of which is determined by option [TT]-grid[tt]."
+    "i.e. the average number of particles within a distance r.[PAR]"
   };
   static gmx_bool bCM=FALSE,bXY=FALSE,bPBC=TRUE,bNormalize=TRUE;
-  static real cutoff=0,binwidth=0.002,grid=0.05,fade=0.0,lambda=0.1,distance=10;
-  static int  npixel=256,nlevel=20,ngroups=1;
-  static real start_q=0.0, end_q=60.0, energy=12.0;
+  static real cutoff=0,binwidth=0.002,fade=0.0;
+  static int  ngroups=1;
 
   static const char *closet[]= { NULL, "no", "mol", "res", NULL };
   static const char *rdft[]={ NULL, "atom", "mol_com", "mol_cog", "res_com", "res_cog", NULL };
@@ -687,60 +681,37 @@ int gmx_rdf(int argc,char *argv[])
     { "-ng",       FALSE, etINT, {&ngroups},
       "Number of secondary groups to compute RDFs around a central group" },
     { "-fade",     FALSE, etREAL, {&fade},
-      "From this distance onwards the RDF is tranformed by g'(r) = 1 + [g(r)-1] exp(-(r/fade-1)^2 to make it go to 1 smoothly. If fade is 0.0 nothing is done." },
-    { "-grid",     FALSE, etREAL, {&grid},
-      "[HIDDEN]Grid spacing (in nm) for FFTs when computing structure factors" },
-    { "-npixel",   FALSE, etINT,  {&npixel},
-      "[HIDDEN]# pixels per edge of the square detector plate" },
-    { "-nlevel",   FALSE, etINT,  {&nlevel},
-      "Number of different colors in the diffraction image" },
-    { "-distance", FALSE, etREAL, {&distance},
-      "[HIDDEN]Distance (in cm) from the sample to the detector" },
-    { "-wave",     FALSE, etREAL, {&lambda},
-      "[HIDDEN]Wavelength for X-rays/Neutrons for scattering. 0.1 nm corresponds to roughly 12 keV" },
-    
-    {"-startq", FALSE, etREAL, {&start_q},
-     "Starting q (1/nm) "},
-    {"-endq", FALSE, etREAL, {&end_q},
-     "Ending q (1/nm)"},
-    {"-energy", FALSE, etREAL, {&energy},
-     "Energy of the incoming X-ray (keV) "}
+      "From this distance onwards the RDF is tranformed by g'(r) = 1 + [g(r)-1] exp(-(r/fade-1)^2 to make it go to 1 smoothly. If fade is 0.0 nothing is done." }
   };
 #define NPA asize(pa)
-  const char *fnTPS,*fnNDX,*fnDAT=NULL;
-  gmx_bool       bSQ,bRDF;
+  const char *fnTPS,*fnNDX;
   output_env_t oenv;
   
   t_filenm   fnm[] = {
     { efTRX, "-f",  NULL,     ffREAD },
     { efTPS, NULL,  NULL,     ffOPTRD },
     { efNDX, NULL,  NULL,     ffOPTRD },
-    { efDAT, "-d",  "sfactor",     ffOPTRD },
-    { efXVG, "-o",  "rdf",    ffOPTWR },
-    { efXVG, "-sq", "sq",     ffOPTWR },
+    { efXVG, "-o",  "rdf",    ffWRITE },
     { efXVG, "-cn", "rdf_cn", ffOPTWR },
     { efXVG, "-hq", "hq",     ffOPTWR },
-/*    { efXPM, "-image", "sq",  ffOPTWR }*/
   };
 #define NFILE asize(fnm)
-  
+
   CopyRight(stderr,argv[0]);
   parse_common_args(&argc,argv,PCA_CAN_VIEW | PCA_CAN_TIME | PCA_BE_NICE,
-                   NFILE,fnm,NPA,pa,asize(desc),desc,0,NULL,&oenv);
+                    NFILE,fnm,NPA,pa,asize(desc),desc,0,NULL,&oenv);
 
-  bSQ   = opt2bSet("-sq",NFILE,fnm);
-  if (bSQ)
-    please_cite(stdout,"Cromer1968a");
-
-  bRDF  = opt2bSet("-o",NFILE,fnm) || !bSQ;
-  if (bSQ || bCM || closet[0][0]!='n' || rdft[0][0]=='m' || rdft[0][6]=='m') {
-    fnTPS = ftp2fn(efTPS,NFILE,fnm);
-    fnDAT = ftp2fn(efDAT,NFILE,fnm);
+  if (bCM || closet[0][0]!='n' || rdft[0][0]=='m' || rdft[0][6]=='m') {
+      fnTPS = ftp2fn(efTPS,NFILE,fnm);
   } else {
-    fnTPS = ftp2fn_null(efTPS,NFILE,fnm);
+      fnTPS = ftp2fn_null(efTPS,NFILE,fnm);
   }
   fnNDX = ftp2fn_null(efNDX,NFILE,fnm);
 
+  if (!fnTPS && !fnNDX)
+      gmx_fatal(FARGS,"Neither index file nor topology file specified\n"
+                "Nothing to do!");
+
   if (closet[0][0] != 'n') {
     if (bCM) {
       gmx_fatal(FARGS,"Can not have both -com and -surf");
@@ -751,23 +722,13 @@ int gmx_rdf(int argc,char *argv[])
     }
   }
 
-  if (!bSQ && (!fnTPS && !fnNDX))
-    gmx_fatal(FARGS,"Neither index file nor topology file specified\n"
-             "Nothing to do!");
-  if  (bSQ) 
-   do_scattering_intensity(fnTPS,fnNDX,opt2fn("-sq",NFILE,fnm),
-                           ftp2fn(efTRX,NFILE,fnm),fnDAT,
-                          start_q, end_q, energy, ngroups,oenv);
-
-  if (bRDF) 
-    do_rdf(fnNDX,fnTPS,ftp2fn(efTRX,NFILE,fnm),
-          opt2fn("-o",NFILE,fnm),opt2fn_null("-cn",NFILE,fnm),
-          opt2fn_null("-hq",NFILE,fnm),
-          bCM,closet[0],rdft,bXY,bPBC,bNormalize,cutoff,binwidth,fade,ngroups,
-           oenv);
+  do_rdf(fnNDX,fnTPS,ftp2fn(efTRX,NFILE,fnm),
+         opt2fn("-o",NFILE,fnm),opt2fn_null("-cn",NFILE,fnm),
+         opt2fn_null("-hq",NFILE,fnm),
+         bCM,closet[0],rdft,bXY,bPBC,bNormalize,cutoff,binwidth,fade,ngroups,
+         oenv);
 
   thanx(stderr);
-  
+
   return 0;
 }
diff --git a/src/tools/gmx_saxs.c b/src/tools/gmx_saxs.c
new file mode 100644 (file)
index 0000000..9da9771
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * 
+ *                This source code is part of
+ * 
+ *                 G   R   O   M   A   C   S
+ * 
+ *          GROningen MAchine for Chemical Simulations
+ * 
+ *                        VERSION 3.2.0
+ * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
+ * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
+ * Copyright (c) 2001-2004, The GROMACS development team,
+ * check out http://www.gromacs.org for more information.
+
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * If you want to redistribute modifications, please consider that
+ * scientific software is very special. Version control is crucial -
+ * bugs must be traceable. We will be happy to consider code for
+ * inclusion in the official distribution, but derived work must not
+ * be called official GROMACS. Details are found in the README & COPYING
+ * files - if they are missing, get the official version at www.gromacs.org.
+ * 
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the papers on the package - you can find them in the top README file.
+ * 
+ * For more info, check our website at http://www.gromacs.org
+ * 
+ * And Hey:
+ * Green Red Orange Magenta Azure Cyan Skyblue
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <math.h>
+#include <ctype.h>
+#include "string2.h"
+#include "sysstuff.h"
+#include "typedefs.h"
+#include "macros.h"
+#include "vec.h"
+#include "pbc.h"
+#include "xvgr.h"
+#include "copyrite.h"
+#include "futil.h"
+#include "statutil.h"
+#include "tpxio.h"
+#include "physics.h"
+#include "index.h"
+#include "smalloc.h"
+#include "calcgrid.h"
+#include "nrnb.h"
+#include "coulomb.h"
+#include "gstat.h"
+#include "matio.h"
+#include "gmx_ana.h"
+#include "names.h"
+#include "sfactor.h"
+
+int gmx_saxs(int argc,char *argv[])
+{
+    const char *desc[] = {
+        "g_saxs calculates SAXS structure factors for given index groups based on Cromer's method.",
+        "Both topology and trajectory files are required."
+    };
+
+    static real start_q=0.0, end_q=60.0, energy=12.0;
+    static int ngroups=1;
+
+    t_pargs pa[] = {
+        { "-ng",       FALSE, etINT, {&ngroups},
+          "Number of groups to compute SAXS" },
+        {"-startq", FALSE, etREAL, {&start_q},
+         "Starting q (1/nm) "},
+        {"-endq", FALSE, etREAL, {&end_q},
+         "Ending q (1/nm)"},
+        {"-energy", FALSE, etREAL, {&energy},
+         "Energy of the incoming X-ray (keV) "}
+    };
+#define NPA asize(pa)
+    const char *fnTPS,*fnTRX,*fnNDX,*fnDAT=NULL;
+    output_env_t oenv;
+
+    t_filenm   fnm[] = {
+        { efTRX, "-f",  NULL,      ffREAD },
+        { efTPS, NULL,  NULL,      ffREAD },
+        { efNDX, NULL,  NULL,      ffOPTRD },
+        { efDAT, "-d",  "sfactor", ffOPTRD },
+        { efXVG, "-sq", "sq",      ffWRITE },
+    };
+#define NFILE asize(fnm)
+
+    CopyRight(stderr,argv[0]);
+    parse_common_args(&argc,argv, PCA_CAN_TIME | PCA_BE_NICE,
+                      NFILE,fnm,NPA,pa,asize(desc),desc,0,NULL,&oenv);
+
+    fnTPS = ftp2fn(efTPS,NFILE,fnm);
+    fnTRX = ftp2fn(efTRX,NFILE,fnm);
+    fnDAT = ftp2fn(efDAT,NFILE,fnm);
+    fnNDX = ftp2fn_null(efNDX,NFILE,fnm);
+
+    do_scattering_intensity(fnTPS,fnNDX,opt2fn("-sq",NFILE,fnm),
+                            fnTRX,fnDAT,
+                            start_q, end_q, energy, ngroups,oenv);
+
+    please_cite(stdout,"Cromer1968a");
+
+    thanx(stderr);
+
+    return 0;
+}