434
434
'You should probably use write_once(\"'+filename+'\") instead.\n')
437
elif ((section_name.lower() == 'bonds by type') or
438
(section_name.lower() == 'bonds bytype') or
439
(section_name.lower() == 'bonds_by_type') or
440
(section_name.lower() == 'bonds_bytype') or
441
(section_name.lower() == 'bondsbytype') or
442
(section_name.lower() == 'bond by type') or
443
(section_name.lower() == 'bond bytype') or
444
(section_name.lower() == 'bond_by_type') or
445
(section_name.lower() == 'bond_bytype') or
446
(section_name.lower() == 'bondbytype')):
447
if (filename != data_bonds_by_type):
448
raise InputError('Probable typo in '+ErrorLeader(srcloc.infile,srcloc.lineno)+'\n\n'+
449
'Output file name (\"'+filename+'\") does not match,\n'
450
'yet overlaps closely with reserved lttree-file name.\n'
451
'Perhaps you meant \"'+data_bonds_by_type+'\"?')
452
elif (write_command != 'write_once'):
453
raise InputError('Probable typo in '+ErrorLeader(srcloc.infile,srcloc.lineno)+'\n\n'+
454
'When using moltemplate.sh to build LAMMPS input files, you probably do not\n'
455
'want to use the '+write_command+'() command with \"'+filename+'\".\n'
456
'You should probably use write_once(\"'+filename+'\") instead.\n')
438
460
elif ((section_name.lower() == 'angles by type') or
439
461
(section_name.lower() == 'angles bytype') or
514
536
'want to use the '+write_command+'() command with \"'+filename+'\".\n'
515
537
'You should probably use write(\"'+filename+'\") instead.\n')
539
elif ((section_name.lower().find('bond list') == 0) or
540
(section_name.lower().find('bonds list') == 0) or
541
(section_name.lower().find('bond_list') == 0) or
542
(section_name.lower().find('bonds_list') == 0)):
543
if (filename != data_bond_list):
544
raise InputError('Probable typo in '+ErrorLeader(srcloc.infile,srcloc.lineno)+'\n\n'+
545
'Output file name (\"'+filename+'\") does not match,\n'
546
'yet overlaps closely with reserved lttree-file name.\n'
547
'Perhaps you meant \"'+data_bonds_by_type+'\"?')
548
elif (write_command != 'write'):
549
raise InputError('Probable typo in '+ErrorLeader(srcloc.infile,srcloc.lineno)+'\n\n'+
550
'When using moltemplate.sh to build LAMMPS input files, you probably do not\n'
551
'want to use the '+write_command+'() command with \"'+filename+'\".\n'
552
'You should probably use write(\"'+filename+'\") instead.\n')
517
555
elif ((section_name.lower() == 'angles') or
518
556
(section_name.lower() == 'angle')):
519
557
if (filename != data_angles):
1016
elif filename == 'Data Bond List':
1017
table = TableFromTemplate(command.tmpl_list,
1018
[[' ', '\t', '\r'], '\n'],
1020
for i in range(0, len(table)):
1022
assert(hasattr(table[i], '__len__'))
1023
if len(table[i]) > 0:
1024
if ((len(table[i]) > 1) and
1025
isinstance(table[i][0], TextBlock) and
1026
(len(table[i][0].text) > 0) and
1027
(table[i][0].text == '#')):
1030
if len(table[i]) < 3:
1032
table_entry = table[i][0]
1033
if (not ((isinstance(table_entry, VarRef)) and
1034
(table_entry.prefix in ('$','${')) and
1035
(ExtractCatName(table_entry.descr_str) == 'bond'))):
1037
if len(table[i]) > 1:
1038
table_entry = table[i][1]
1039
if (not ((isinstance(table_entry, VarRef)) and
1040
(table_entry.prefix in ('$','${')) and
1041
(ExtractCatName(table_entry.descr_str) == 'atom'))):
1043
if len(table[i]) > 2:
1044
table_entry = table[i][2]
1045
if (not ((isinstance(table_entry, VarRef)) and
1046
(table_entry.prefix in ('$','${')) and
1047
(ExtractCatName(table_entry.descr_str) == 'atom'))):
1051
raise InputError('----------------------------------------------------\n'+
1052
' Syntax error near '+
1053
ErrorLeader(table[i][0].srcloc.infile,
1054
table[i][0].srcloc.lineno)+'\n'
1055
' Incorrect "Data Bond List" syntax.\n'+
1056
'Each lines in this section should have this format:\n\n'
1057
' $bond:id $atom:id1 $atom:id2\n'+
1058
'----------------------------------------------------\n'+
978
1062
elif filename == 'Data Angles':
979
1063
table = TableFromTemplate(command.tmpl_list,
980
1064
[[' ', '\t', '\r'], '\n'],
1399
1483
table[i][0].binding))
1486
elif filename == 'Data Bonds By Type':
1487
table = TableFromTemplate(command.tmpl_list,
1488
[[' ','\t','\r'], '\n'],
1490
for i in range(0, len(table)):
1491
if len(table[i]) == 0:
1493
elif ((len(table[i]) > 1) and
1494
isinstance(table[i][0], TextBlock) and
1495
(len(table[i][0].text) > 0) and
1496
(table[i][0].text == '#')):
1497
pass #Ignore comment lines (postprocessing removes them)
1498
elif (not ((len(table[i]) >= 3) and
1499
isinstance(table[i][0], VarRef) and
1500
(table[i][0].prefix in ('@', '@{')) and
1501
(table[i][0].nptr.cat_name == 'bond') and
1502
(table[i][0].nptr.cat_node == root_node))):
1503
raise InputError('----------------------------------------------------\n'+
1504
' Syntax error near '+
1505
ErrorLeader(table[i][0].srcloc.infile,
1506
table[i][0].srcloc.lineno)+'\n'
1507
' Incorrect \"Data Bonds By Type\" syntax.\n'
1508
' Each line of the \"Data Bonds By Type\" section should begin with an\n'
1509
' @bond:type variable followed by 2 atom types.\n'+
1510
'----------------------------------------------------\n'+
1402
1514
elif filename == 'Data Angles By Type':
1403
1515
table = TableFromTemplate(command.tmpl_list,
1404
1516
[[' ','\t','\r'], '\n'],
1814
1926
# if there are more than 2 remaining arguments,
1815
1927
problem_args = ['\"'+arg+'\"' for arg in argv[1:]]
1816
raise InputError('Syntax Error('+__file__+'):\n\n'
1928
raise InputError('Syntax Error('+g_program_name+'):\n\n'
1817
1929
' Unrecognized argument.\n'
1818
1930
' (That or there is some other problem with the argument list.)\n'
1819
1931
' The problem begins with these arguments:\n'
1833
1945
if __name__ == "__main__":
1835
g_program_name = 'lttree_check.py'
1836
g_version_str = '0.72'
1837
g_date_str = '2012-12-15'
1947
g_program_name = __file__.split('/')[-1] # = 'lttree_check.py'
1948
g_version_str = '0.73'
1949
g_date_str = '2013-8-06'
1838
1950
sys.stderr.write(g_program_name+' v'+g_version_str+' '+g_date_str+'\n')