Skip to content

Commit

Permalink
Correction in improper type assignment (only in direct order)
Browse files Browse the repository at this point in the history
  • Loading branch information
craabreu committed Sep 9, 2017
1 parent 84b9c95 commit ef436a9
Show file tree
Hide file tree
Showing 9 changed files with 173 additions and 149 deletions.
5 changes: 1 addition & 4 deletions .hooks/pre-commit
@@ -1,14 +1,11 @@
#!/bin/bash
date=$(LANG=en_US date +"%d %b %Y")

line="'27s/.*/call writeln( \"Playmol ($date)\" )/'"
line="'27s/.*/call writeln( \"Playmol (Version: $date)\" )/'"
eval "sed -i $line ./src/playmol.f90"
git add ./src/playmol.f90

line="'3s/.*/PROJECT_BRIEF = \"(Version: $date)\"/'"
eval "sed -i $line ./docs/Doxyfile"
git add ./docs/Doxyfile

make -C ./docs &> /dev/null
git add ./docs/html/*

2 changes: 1 addition & 1 deletion docs/Doxyfile
@@ -1,6 +1,6 @@
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "Playmol"
PROJECT_BRIEF = "(Version: 23 Aug 2017)"
PROJECT_BRIEF = "(Version: 09 Sep 2017)"
PROJECT_LOGO = playmol_logo.gif
OUTPUT_DIRECTORY = .
OUTPUT_DIRECTORY =
Expand Down
111 changes: 53 additions & 58 deletions docs/commands.md
Expand Up @@ -394,31 +394,25 @@ comment tags (#). When a [LAMMPS data file] is generated using the command [writ
of _attribute-list_ is assumed to be the parameters of the [LAMMPS bond style] associated with the
bond type in question.

Bond types are considered as __identical__ if they are defined by the same identifiers _type-1_ and
_type-2_, in either order. Playmol accepts definitions of identical bond types, which are applied
simultaneously to every defined bond that fits into such identifiers. This is useful, for instance,
when the stretching potential model is a sum of instances of a given [LAMMPS bond style], each one
with a distinct set of parameter values.

Bond types are considered as __ambiguous__ if, despite not being identical, they can fit to the
same defined bond due to the presence of wildcard characters. Playmol accepts definitions of
ambiguous bond types (or ambiguous sets of identical bond types), provided that they do not have
the same number of wildcard-containing identifiers. If a detected bond fits to multiple ambiguous
bond types (or sets thereof), Playmol will only apply the one (type or set) with the least number
of wildcard-containing identifiers.
Playmol is able to resolve __ambiguities__ in definitions of bond types. When several ambiguous
bond types fit to a defined [bond] or [extra] bond, Playmol will classify them according to the
number _N_ of wildcard-containing identifiers (_N_ = 0, 1, or 2). Then, it will simultaneously
assign to the bond all those types with the smallest found value of _N_. Multiple assignments are
useful, for instance, when the stretching potential model is a sum of instances of a given
[LAMMPS bond style], each one with a distinct set of parameter values.

**Examples**:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bond_type CH* CH* 95.877 1.54
bond_type CH* CH* harmonic 95.877 1.54
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In the example above, the given attributes will be associated with every bond involving atoms whose
types have identifiers starting with _CH_.

**See also**:

[atom_type], [bond], [write], [prefix/suffix]
[atom_type], [bond], [write], [prefix/suffix], [extra]

----------------------------------------------------------------------------------------------------
<a name="angle_type"></a>
Expand Down Expand Up @@ -462,23 +456,17 @@ the moment a new angle is detected, then Playmol will ignore such angle and prod
message. Besides the automatic detection, an angle can also be explicitly created using the [extra]
command.

Angle types are considered as __identical__ if they are defined by the same sequence of identifiers
_type-1_, _type-2_, and _type-3_, in either the direct or the reverse order. Playmol accepts
definitions of identical angle types, which are applied simultaneously to every detected angle that
fits into such sequence. This is useful, for instance, when the bending potential model is a sum of
instances of a given [LAMMPS angle style], each one with a distinct set of parameter values.

Angle types are considered as __ambiguous__ if, despite not being identical, they can fit to the
same detected angle due to the presence of wildcard characters. Playmol accepts definitions of
ambiguous angle types (or ambiguous sets of identical angle types), provided that they do not have
the same number of wildcard-containing identifiers. If a detected angle fits to multiple ambiguous
angle types (or sets thereof), Playmol will only apply the one (type or set) with the least number
of wildcard-containing identifiers.
Playmol is able to resolve __ambiguities__ in definitions of angle types. When several ambiguous
angle types fit to a detected angle or defined [extra] angle, Playmol will classify them according
to the number _N_ of wildcard-containing identifiers (_N_ = 0, 1, 2, or 3). Then, it will
simultaneously assign to the angle all those types with the smallest found value of _N_. Multiple
assignments are useful, for instance, when the bending potential model is a sum of instances of
a given [LAMMPS angle style], each one with a distinct set of parameter values.

**Examples**:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
angle_type CH3 CH2 CH2 62.0965 114
angle_type CH3 CH2 CH2 harmonic 62.0965 114
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In the example above, the given attributes will be associated with every detected or specified angle
Expand Down Expand Up @@ -509,7 +497,7 @@ the types of the four atoms involved.

The parameters _type-1_, _type-2_, _type-3_, and _type-4_ are identifiers of previously defined atom
types. The order of such identifiers is relevant in the case of dihedral types, that is, if the same
identifiers are disposed in the inverse order, they will denote a different dihedral type. Wildcard
identifiers are disposed in the inverse order, they will denote different dihedral types. Wildcard
characters (? and *) can be used to refer to multiple atom types. If a type-related [prefix/suffix]
has been previously activated, then each actual atom type identifier will contain such prefix and/or
suffix added to _type-x_.
Expand All @@ -532,23 +520,33 @@ does not exist at the moment a new dihedral is detected, then Playmol will ignor
produce a warning message. Besides the automatic detection, a dihedral can also be explicitly
created using the [extra] command.

Dihedral types are considered as __identical__ if they are defined by the same sequence of
identifiers _type-1_, _type-2_, _type-3_, and _type-4_. Playmol accepts definitions of identical
dihedral types, which are applied simultaneously to every detected dihedral that fits into such
sequence. This is useful, for instance, when the torsional potential model is a sum of instances
of a given [LAMMPS dihedral style], each one with a distinct set of parameter values.

Dihedral types are considered as __ambiguous__ if, despite not being identical, they can fit to the
same detected dihedral due to the presence of wildcard characters. Playmol accepts definitions of
ambiguous dihedral types (or ambiguous sets of identical dihedral types), provided that they do not
have the same number of wildcard-containing identifiers. If a detected dihedral fits to multiple
ambiguous dihedral types (or sets thereof), Playmol will only apply the one (type or set) with the
least number of wildcard-containing identifiers.
Playmol is able to resolve __ambiguities__ in definitions of dihedral types. When several ambiguous
dihedral types fit to a detected dihedral or defined [extra] dihedral, Playmol will classify them
according to the number _N_ of wildcard-containing identifiers (_N_ = 0, 1, 2, 3, or 4). Then, it
will simultaneously assign to the dihedral all those types with the smallest found value of _N_.
Multiple assignments are useful, for instance, when the torsional potential model is a sum of
instances of a given [LAMMPS dihedral style], each one with a distinct set of parameter values.

__NOTE__: Because the direction of identifiers is relevant in the definition of a dihedral type, a
__direction conflict__ might occur when multiple dihedral types are simultaneously assigned to a
detected or defined dihedral. Such a conflict takes place when all the following three conditions
are met:

1. Some types fit to the dihedral exclusively in the direct order;
2. Some types fit exclusively in the reverse order;
3. Some other types can fit in either the direct or reverse order.

Combinations of conditions (1) and (3) are okay. Playmol automatically solves a combination of (2)
and (3) by flipping the new dihedral before inclusion. It also solves automatically a combination
of (1) and (2) by including a flipped dihedral in addition to the original one. However, Playmol
will only throw a warning message when faced with a combination of all three conditions. In this
case, the user can try to solve the conflict by manually flipping the dihedral types that cause
condition (2), for instance.

**Examples**:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dihedral_type CH3 CH2 CH2 CH2 1.41095 -0.27100 3.14484 0
dihedral_type CH3 CH2 CH2 CH2 opls 1.41095 -0.27100 3.14484 0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In the example above, the given attributes will be associated with every detected or specified
Expand Down Expand Up @@ -579,7 +577,7 @@ the types of the four atoms involved.

The parameters _type-1_, _type-2_, _type-3_, and _type-4_ are identifiers of previously defined atom
types. The order of such identifiers is relevant in the case of improper types, that is, if the same
identifiers are disposed in the inverse order, they will denote a different improper type. Wildcard
identifiers are disposed in the inverse order, they will denote different improper types. Wildcard
characters (? and *) can be used to refer to multiple atom types. If a type-related [prefix/suffix]
has been previously activated, then each actual atom type identifier will contain such prefix and/or
suffix added to _type-x_.
Expand All @@ -600,32 +598,29 @@ defined. This is so because there are distinct possible definitions of improper
must be manually created by using the [improper] command, which requires the previous definition of
a fitting improper type.

Improper types are considered as __identical__ if they are defined by the same sequence of
identifiers _type-1_, _type-2_, _type-3_, and _type-4_. Playmol accepts definitions of identical
improper types, which are applied simultaneously to every defined improper that fits into such
sequence. This is useful, for instance, when the improper potential model is a sum of instances
of a given [LAMMPS improper style], each one with a distinct set of parameter values.
Playmol is able to resolve __ambiguities__ in definitions of improper types. When several ambiguous
improper types fit to a defined improper, Playmol will classify them according to the number _N_
of wildcard-containing identifiers (_N_ = 0, 1, 2, 3, or 4). Then, it will simultaneously assign
to the improper all those types with the smallest found value of _N_. Multiple assignments are
useful, for instance, when the torsional potential model is a sum of instances of a given
[LAMMPS improper style], each one with a distinct set of parameter values.

Improper types are considered as __ambiguous__ if, despite not being identical, they can fit to the
same defined improper due to the presence of wildcard characters. Playmol accepts definitions of
ambiguous improper types (or ambiguous sets of identical improper types), provided that they do not
have the same number of wildcard-containing identifiers. If a defined improper fits to multiple
ambiguous improper types (or sets thereof), Playmol will only apply the one (type or set) with the
least number of wildcard-containing identifiers.
__NOTE__: Improper types are only assigned to an [improper] if they match the atom types of the
improper atoms in the exact order they are defined.

**Examples**:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
improper_type CH3 CH2 CH2 CH2 1.41095 -0.27100 3.14484 0
improper_type c2 c2 na c3 cvff 1.1 -1 2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In the example above, the given attributes will be associated with every detected or specified
improper that involves four consecutive atoms whose type identifiers are _CH3_ _CH2_ _CH2_ _CH2_,
in this specific order.
improper that involves four atoms whose type identifiers are _c2_ _c2_ _na_ _c3_, in this specific
order.

**See also**:

[atom_type], [improper], [write], [prefix/suffix]
[atom_type], [improper], [write], [prefix/suffix], [extra]

----------------------------------------------------------------------------------------------------
<a name="atom"></a>
Expand Down Expand Up @@ -936,7 +931,7 @@ or
**Description**:

This command creates an extra structure (bond, angle, dihedral) involving the specified atoms. In
the case of an extra angle or extra dihedral, all specified atoms must belong to the same molecule.
the case of an extra angle or extra dihedral, all specified atoms must belong to the same molecule.

The parameter _atom-x_ is the identifier of a previously created atom. A unique identifier must be
provided, with no use of wildcard characters (* or ?). A corresponding structure type (that is,
Expand Down
2 changes: 1 addition & 1 deletion examples/linear-hydrocarbons/linear-hydrocarbons.mol
Expand Up @@ -2,7 +2,7 @@ define N as 5
define FF as nerd
define seed as 3467
define nmols as 500
define rho as 0.6 # g/cm³
define rho as 0.3 # g/cm³
define temp as 180 # K

mass CH4 16.04242 # Da
Expand Down
4 changes: 3 additions & 1 deletion examples/linear-hydrocarbons/nerd.mol
Expand Up @@ -21,6 +21,8 @@ endif
atom_type CH4 lj/cut {148.0*$kB} 3.730 $cutoff # TraPPE parameters

bond_type CH? CH? harmonic {96500*$kB/2} $L
angle_type CH? CH? CH? harmonic {62500*$kB/2} $theta
#angle_type CH? CH? CH? harmonic {62500*$kB/2} $theta
dihedral_type CH3 CH2 CH2 CH? opls {355.04*2*$kB} {-68.19*2*$kB} {701.32*2*$kB} 0.0
dihedral_type CH? CH2 CH2 CH3 opls {355.04*2*$kB} {-68.19*2*$kB} {701.32*2*$kB} 0.0
dihedral_type CH? CH2 CH2 CH? opls {355.04*2*$kB} {-68.19*2*$kB} {701.32*2*$kB} 0.0

14 changes: 9 additions & 5 deletions src/mGlobal.f90
Expand Up @@ -23,7 +23,11 @@ module mGlobal

integer, parameter :: rb = 8 !< Default number of bytes for real numbers
integer, parameter :: sl = 256 !< Default character string length
character(3), parameter :: csl = "256" !< String with default character string length
character(*), parameter :: csl = "256" !< String with default character string length

character(*), parameter :: yellow = achar(27)//"[1;93m", &
red = achar(27)//"[1;91m", &
decolor = achar(27)//"[0m"

integer :: stdout = 6 !< Standard output unit
integer :: logunit = 0 !< Output unit for logging
Expand Down Expand Up @@ -123,7 +127,7 @@ subroutine warning( msg, msg1, msg2, msg3, msg4, msg5, msg6, msg7, msg8, msg9 )
if (present(msg7)) wmsg = trim(wmsg)//" "//trim(msg7)
if (present(msg8)) wmsg = trim(wmsg)//" "//trim(msg8)
if (present(msg9)) wmsg = trim(wmsg)//" "//trim(msg9)
write(stdout,'(A)') achar(27)//"[1;93mWARNING: "//trim(wmsg)//achar(27)//"[0m"
write(stdout,'(A)') yellow//"WARNING: "//trim(wmsg)//decolor
if (logunit /= 0) write(logunit,'(A)') "WARNING: "//trim(wmsg)
last_warning % msg = wmsg
end subroutine warning
Expand All @@ -135,8 +139,8 @@ subroutine reprint_warnings
ptr => first_warning
if (associated(ptr)) then
call writeln()
write(stdout,'(A)') achar(27)//"[1;93m*** SUMMARY OF WARNINGS ***"//achar(27)//"[0m"
if (logunit /= 0) write(logunit,'("********** SUMMARY OF WARNINGS **********")')
write(stdout,'(A)') yellow//"******** SUMMARY OF WARNINGS ********"//decolor
if (logunit /= 0) write(logunit,'("******** SUMMARY OF WARNINGS ********")')
end if
do while (associated(ptr))
call writeln( ">", ptr % msg )
Expand All @@ -160,7 +164,7 @@ subroutine error( msg, msg1, msg2, msg3, msg4, msg5, msg6, msg7, msg8, msg9 )
if (present(msg7)) emsg = trim(emsg)//" "//trim(msg7)
if (present(msg8)) emsg = trim(emsg)//" "//trim(msg8)
if (present(msg9)) emsg = trim(emsg)//" "//trim(msg9)
write(stdout,'(A)') achar(27)//"[1;91mERROR"//achar(27)//"[0m: "//trim(emsg)
write(stdout,'(A)') red//"ERROR"//decolor//": "//trim(emsg)
if (logunit /= 0) write(logunit,'(A)') "ERROR: "//trim(emsg)
stop
end subroutine error
Expand Down
8 changes: 4 additions & 4 deletions src/mPlaymol.f90
Expand Up @@ -62,8 +62,8 @@ module mPlaymol
type(StrucList) :: bond_list = StrucList( "bond", 2 )
type(StrucList) :: link_list = StrucList( "virtual link", 2 )
type(StrucList) :: angle_list = StrucList( "angle", 3 )
type(StrucList) :: dihedral_list = StrucList( "dihedral", 4, reversible = .false. )
type(StrucList) :: improper_list = StrucList( "improper", 4, reversible = .false. )
type(StrucList) :: dihedral_list = StrucList( "dihedral", 4, .false., .true. )
type(StrucList) :: improper_list = StrucList( "improper", 4, .false. )
type(StrucList) :: body_list = StrucList( "rigid body" )
type(StrucList) :: atom_bodies = StrucList( "atom body" )
type(StrucList) :: mixing_rule_list = StrucList( "mixing rule", 2 )
Expand Down Expand Up @@ -982,7 +982,7 @@ subroutine tPlaymol_analyze_struct( me, structure, permol, total, type_map, list
if (ptr % usable) then
do i = 1, list%count
associate (s => structure(i))
if (list%reversible) then
if (list%bothways) then
match = ptr % match_id( s%atom_types )
else
match = all(match_str( ptr%id, s%atom_types ))
Expand All @@ -1008,7 +1008,7 @@ subroutine tPlaymol_analyze_struct( me, structure, permol, total, type_map, list
if (any(s%wildcards /= s%wildcards(1))) then
valid = s%wildcards == minval(s%wildcards)
call warning( "ambiguity resolved for", list%name, join(s%atoms), &
"( types", join(s%atom_types), ")" )
"( atom types", join(s%atom_types), ")" )
aux = pack(s%itype,valid)
ptr => typelist % first
do itype = 1, typelist % count
Expand Down

0 comments on commit ef436a9

Please sign in to comment.