ESPResSo 3.2.0-11-g9950804-git
Extensible Simulation Package for Soft Matter Research
mdlc_correction_tcl.c
Go to the documentation of this file.
00001 /*
00002   Copyright (C) 2010,2011,2012,2013 The ESPResSo project
00003   Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010 
00004     Max-Planck-Institute for Polymer Research, Theory Group
00005   
00006   This file is part of ESPResSo.
00007   
00008   ESPResSo is free software: you can redistribute it and/or modify
00009   it under the terms of the GNU General Public License as published by
00010   the Free Software Foundation, either version 3 of the License, or
00011   (at your option) any later version.
00012   
00013   ESPResSo is distributed in the hope that it will be useful,
00014   but WITHOUT ANY WARRANTY; without even the implied warranty of
00015   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016   GNU General Public License for more details.
00017   
00018   You should have received a copy of the GNU General Public License
00019   along with this program.  If not, see <http://www.gnu.org/licenses/>. 
00020 */
00021 /** \file mdlc_correction_tcl.c
00022  *
00023  *  Implementation of \ref mdlc_correction_tcl.h
00024  */
00025 #include "mdlc_correction_tcl.h"
00026 #include "mdlc_correction.h"
00027 
00028 #ifdef DIPOLES
00029 
00030 int tclprint_to_result_MDLC(Tcl_Interp *interp)
00031 {
00032   char buffer[TCL_DOUBLE_SPACE];
00033   
00034   Tcl_PrintDouble(interp, dlc_params.maxPWerror, buffer);
00035  Tcl_AppendResult(interp, "} {magnetic mdlc ", buffer, (char *) NULL);
00036   Tcl_PrintDouble(interp, dlc_params.gap_size, buffer);
00037   Tcl_AppendResult(interp, " ", buffer, (char *) NULL);
00038   Tcl_PrintDouble(interp, dlc_params.far_cut, buffer);
00039   Tcl_AppendResult(interp, " ", buffer, (char *) NULL);
00040   return TCL_OK;
00041 }
00042 /* ***************************************************************** */
00043 
00044 int tclcommand_inter_magnetic_parse_mdlc_params(Tcl_Interp * interp, int argc, char ** argv)
00045 {
00046   double pwerror;
00047   double gap_size;
00048   double far_cut = -1;
00049  
00050   MDLC_TRACE(fprintf(stderr, "%d: tclcommand_inter_magnetic_parse_mdlc_params().\n", this_node));
00051   
00052   if (argc < 2) {
00053     Tcl_AppendResult(interp, "either nothing or mdlc <pwerror> <minimal layer distance> {<cutoff>}  expected, not \"", argv[0], "\"", (char *)NULL);
00054     return TCL_ERROR;
00055   }
00056   if (!ARG0_IS_D(pwerror))
00057     return TCL_ERROR;
00058   if (!ARG1_IS_D(gap_size))
00059     return TCL_ERROR;
00060 
00061   argc -= 2; argv += 2;
00062 
00063   if (argc > 0) {
00064     // if there, parse away manual cutoff
00065     if(ARG0_IS_D(far_cut)) {
00066       argc--; argv++;
00067     }
00068     else
00069       Tcl_ResetResult(interp);
00070 
00071     if(argc > 0) {
00072         Tcl_AppendResult(interp, "either nothing or mdlc <pwerror> <minimal layer distance=size of the gap without particles> {<cutoff>}   expected, not \"", argv[0], "\"", (char *)NULL);
00073         return TCL_ERROR;
00074     }
00075   }
00076 
00077   CHECK_VALUE(mdlc_set_params(pwerror,gap_size,far_cut),
00078               "choose a 3d electrostatics method prior to use mdlc");
00079 }
00080 /* ***************************************************************** */
00081 
00082 #endif