ESPResSo 3.2.0-11-g9950804-git
Extensible Simulation Package for Soft Matter Research
dihedral_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 dihedral_tcl.c
00022  *
00023  *  Parser for the dihedral potential
00024  */
00025 #include "dihedral_tcl.h"
00026 #include "dihedral.h"
00027 
00028 /// parse parameters for the dihedral potential
00029 int tclcommand_inter_parse_dihedral(Tcl_Interp *interp, int bond_type, int argc, char **argv)
00030 {
00031   int mult;
00032   double bend, phase;
00033 
00034   if (argc < 4 ) {
00035     Tcl_AppendResult(interp, "dihedral needs 3 parameters: "
00036                      "<mult> <bend> <phase>", (char *) NULL);
00037     return (TCL_ERROR);
00038   }
00039   if ( !ARG_IS_I(1, mult) || !ARG_IS_D(2, bend) || !ARG_IS_D(3, phase) ) {
00040     Tcl_AppendResult(interp, "dihedral needs 3 parameters of types INT DOUBLE DOUBLE: "
00041                      "<mult> <bend> <phase> ", (char *) NULL);
00042     return TCL_ERROR;
00043   }
00044   
00045   CHECK_VALUE(dihedral_set_params(bond_type, mult, bend, phase), "bond type must be nonnegative");
00046 }
00047 
00048 int tclprint_to_result_dihedralIA(Tcl_Interp *interp,
00049                                   Bonded_ia_parameters *params)
00050 {
00051   char buffer[TCL_DOUBLE_SPACE];
00052   sprintf(buffer, "%d", (int)(params->p.dihedral.mult));
00053   Tcl_AppendResult(interp, "dihedral ", buffer, " ", (char *) NULL);
00054   Tcl_PrintDouble(interp, params->p.dihedral.bend, buffer);
00055   Tcl_AppendResult(interp, buffer, " ", (char *) NULL);
00056   Tcl_PrintDouble(interp, params->p.dihedral.phase, buffer);
00057   Tcl_AppendResult(interp, buffer, (char *) NULL);
00058   return TCL_OK;
00059 }