diff --git a/doc/src/kim_commands.txt b/doc/src/kim_commands.txt index f9615b8d5f..2a8f83e7a8 100644 --- a/doc/src/kim_commands.txt +++ b/doc/src/kim_commands.txt @@ -35,7 +35,7 @@ kim_init Sim_LAMMPS_ReaxFF_StrachanVanDuinChakraborty_2003_CHNO__SM_107643900657 kim_interactions C H O kim_init Sim_LAMMPS_IFF_OtherInfo_AuthorList_Year_Species__SM_064312669787_000 real kim_interactions fixed_types -kim_query a0 get_lattice_constant_fcc species=\["Al"] units=\["angstrom"\] :pre +kim_query a0 get_lattice_constant_fcc species=\["Al"\] units=\["angstrom"\] :pre [Description:] @@ -105,12 +105,16 @@ The URL for such a page is constructed from the "extended KIM ID"_https://openkim.org/about-kim-ids/ of the IM: https://openkim.org/id/extended_KIM_ID +or +https://openkim.org/id/short_KIM_ID :pre For example for the Stillinger-Weber potential listed above the Model Page is located at: "https://openkim.org/id/SW_StillingerWeber_1985_Si__MO_405512056662_005"_https://openkim.org/id/SW_StillingerWeber_1985_Si__MO_405512056662_005 +or +"https://openkim.org/id/MO_405512056662_005"_https://openkim.org/id/MO_405512056662_005 :pre See the "current list of KIM PMs and SMs archived in OpenKIM"_https://openkim.org/browse/models/by-species. @@ -271,8 +275,8 @@ OpenKIM IM Execution ({kim_interactions}) :h5 The second and final step in using an OpenKIM IM is to execute the {kim_interactions} command. This command must be preceded by a {kim_init} -command and a "create_box"_create_box.html command, -which defines the number of atom types {N}. +command and a command that creates the simulation box (such as +"create_box"_create_box.html), which defines the number of atom types {N}. The {kim_interactions} command has one argument {typeargs}. This argument contains either a list of {N} chemical species, which defines a mapping between atom types in LAMMPS to the available species in the OpenKIM IM, or the @@ -338,7 +342,7 @@ Note also that parameters like cutoff radii and charge tolerances, which have an effect on IM predictions, are also included in the SM definition ensuring reproducibility. -NOTE: When using using {kim_init} and {kim_interactions} to select +NOTE: When using {kim_init} and {kim_interactions} to select and set up an OpenKIM IM, other LAMMPS commands for the same functions (such as pair_style, pair_coeff, bond_style, bond_coeff, fixes related to charge equilibration, etc.) should normally @@ -356,7 +360,7 @@ argument of the {kim_query command}. The second required argument (e.g. {get_lattice_constant_fcc}). All following arguments are parameters handed over to the web query in the format {keyword=value}. The list of supported keywords and -and the type and format of their values depend on the query function +the type and format of their values depend on the query function used. NOTE: The current list of supported query functions is available on the OpenKIM diff --git a/src/KIM/kim_query.cpp b/src/KIM/kim_query.cpp index cf4efc2b12..6e77b8f859 100644 --- a/src/KIM/kim_query.cpp +++ b/src/KIM/kim_query.cpp @@ -124,7 +124,7 @@ void KimQuery::command(int narg, char **arg) // that was returned by the web server if (0 == strlen(value)) { - char errmsg[512]; + char errmsg[1024]; sprintf(errmsg,"OpenKIM query failed: %s",value+1); error->all(FLERR,errmsg); @@ -138,6 +138,8 @@ void KimQuery::command(int narg, char **arg) varcmd[1] = (char *) "string"; while(std::getline(ss, token, ',')) { + token.erase(0,token.find_first_not_of(" \n\r\t")); // ltrim + token.erase(token.find_last_not_of(" \n\r\t") + 1); // rtrim std::stringstream splitname; splitname << varname << "_" << counter++; varcmd[0] = const_cast(splitname.str().c_str()); @@ -256,9 +258,15 @@ char *do_query(char *qfunction, char * model_name, int narg, char **arg, if (value[0] == '[') { int len = strlen(value)-1; - retval = new char[len]; - value[len] = '\0'; - strcpy(retval,value+1); + if (value[len-1] == ']') { + retval = new char[len]; + value[len-1] = '\0'; + strcpy(retval,value+1); + } else { + retval = new char[len+2]; + retval[0] = '\0'; + strcpy(retval+1,value); + } } else if (value[0] == '\0') { int len = strlen(value+1)+2; retval = new char[len]; @@ -266,10 +274,11 @@ char *do_query(char *qfunction, char * model_name, int narg, char **arg, strcpy(retval+1,value+1); } else { // unknown response type. we should not get here. - // copy response without modifications. - int len = strlen(value)+1; + // we return an "empty" string but add error message after it + int len = strlen(value)+2; retval = new char[len]; - strcpy(retval,value); + retval[0] = '\0'; + strcpy(retval+1,value); } return retval; }