How to merge two lammps data file?
def read_lammps_data(file_path):
with open(file_path, 'r') as file:
data = file.readlines()
sections = {
'header': [],
'masses': [],
'atoms': [],
'bonds': [],
'angles': [],
'dihedrals': []
}
current_section = None
for line in data:
if 'Masses' in line:
current_section = 'masses'
elif 'Atoms' in line:
current_section = 'atoms'
elif 'Bonds' in line:
current_section = 'bonds'
elif 'Angles' in line:
current_section = 'angles'
elif 'Dihedrals' in line:
current_section = 'dihedrals'
elif len(line.strip()) == 0:
elif current_section is not None:
sections[current_section].append(line.strip())
else:
sections['header'].append(line.strip())
return sections
def merge_lammps_data(file1, file2, output_file):
data1 = read_lammps_data(file1)
data2 = read_lammps_data(file2)
merged_data = {
atom_offset = len(data1['atoms'])
bond_offset = len(data1['bonds'])
angle_offset = len(data1['angles'])
dihedral_offset = len(data1['dihedrals'])
# Merge headers (simplified, you may need to merge carefully depending on the content)
merged_data['header'] = data1['header'][:3]
merged_data['header'][2] = f"{atom_offset + len(data2['atoms'])} atoms"
merged_data['header'][3] = f"{bond_offset + len(data2['bonds'])} bonds"
merged_data['header'][4] = f"{angle_offset + len(data2['angles'])} angles"
merged_data['header'][5] = f"{dihedral_offset + len(data2['dihedrals'])} dihedrals"
# Merge masses (assuming same types in both files)
merged_data['masses'] = data1['masses']
# Merge atoms
merged_data['atoms'].extend(data1['atoms'])
for atom in data2['atoms']:
parts = atom.split()
parts[0] = str(int(parts[0]) + atom_offset) # Update atom ID
merged_data['atoms'].append(" ".join(parts))
# Merge bonds
merged_data['bonds'].extend(data1['bonds'])
for bond in data2['bonds']:
parts = bond.split()
parts[0] = str(int(parts[0]) + bond_offset) # Update bond ID
parts[2] = str(int(parts[2]) + atom_offset) # Update atom IDs
parts[3] = str(int(parts[3]) + atom_offset)
merged_data['bonds'].append(" ".join(parts))
# Merge angles
merged_data['angles'].extend(data1['angles'])
for angle in data2['angles']:
parts = angle.split()
parts[0] = str(int(parts[0]) + angle_offset) # Update angle ID
parts[4] = str(int(parts[4]) + atom_offset)
merged_data['angles'].append(" ".join(parts))
# Merge dihedrals
merged_data['dihedrals'].extend(data1['dihedrals'])
for dihedral in data2['dihedrals']:
parts = dihedral.split()
parts[0] = str(int(parts[0]) + dihedral_offset) # Update dihedral ID
parts[5] = str(int(parts[5]) + atom_offset)
merged_data['dihedrals'].append(" ".join(parts))
with open(output_file, 'w') as file:
for section in ['header', 'masses', 'atoms', 'bonds', 'angles', 'dihedrals']:
file.write("\n".join(merged_data[section]) + "\n\n")
# Usage
merge_lammps_data('file1.data', 'file2.data', 'merged.data')
Muamar Jasim Thanks a lot.
How to assign atomic charges on bio-molecules which were built by a Glycam Carbohydrate builder? The (.pdb) files generated by carbo-builder are without charges of the atom,? Any help would be...
03 December 2020 8,964 1 View
I would like to determine the thickness of a liquid film floating (uniformly/non-uniformly) on another immiscible liquid. How to photograph the cross section of the film (in a non-invasive manner)...
03 November 2020 5,514 3 View
I am doing co-immunostain using frozen spinal cord sections for IHC. Is it required to perform the antigen retrieval step prior to the blocking step ?
20 August 2020 4,144 0 View
Based on learned reviewers given comments and suggestions I have made corrections of my manuscript and resubmit the updated version. In this stage why does it is showing as "Editor Assigned" for...
25 July 2020 5,162 3 View
Hi all, I am performing steered molecular dynamics simulation of two polymer chains parallel to each other. Then, one chain has pulled using constant velocity and the trajectory I got is...
23 July 2020 7,805 2 View
I have to collect mice embryos for my research and genotype them for KO gene. In PCR, the floxed band is always blur compare to control (control DNA from adult mice) (please see the attached...
02 June 2020 4,234 3 View
i. Although the suggested correction was very less raised by the 2 reviewers in their 2nd revision, why does the editor asked for major revision? ii. Why does the editor has given me clues to...
01 June 2020 711 12 View
Hi All, I have build the model of cellulose polymer using xleap and hemicellulose polymer using glycam carbohydrate builder. Now, I need to place the two polymer chain parallel two each other....
20 May 2020 9,416 1 View
I have a georeferenced image . Is it possible to extract a particular feature like drainage or roads from the geotiff based on its colour and save it as a shapefile using python?
16 March 2020 6,582 1 View
I have a drainage/ river shapefile. If i identify a particular pattern/ feature in the drainage file then using it as input is it possible to identify similar features in the rest of the drainage...
29 January 2020 9,526 3 View
Hi, Could you help me to get the latest (2019, 2020) solar resource data for a particular site in JAPAN? PV GIS and NSRDB data are not in reach to JAPAN, I'm looking for some other database for...
03 March 2021 961 3 View
How do I do energy minimization in lammps with NVT ensemble ? I am using the following command and it does not seem to work. It stops at extremely high energy and gives me the error zero search...
01 March 2021 2,294 3 View
I have created an Ice 1h crystalline structure and an Aluminium substrate structure and equilibrated both at 250K. Now I need to bring them together in a way that an adhesive bond is created....
01 March 2021 3,325 2 View
My master's research is in info retrieval and text mining. I would be grateful if you could help me to select a good topic for my phd research proposal.
24 February 2021 393 14 View
Hello, I'm very interested in mapping and managing the conservation of the Philippine traditional medicinal plants, in which I think is very helpful in the field of medicine for further analysis...
21 February 2021 374 5 View
Is there any way to construct different initial filler shapes like triangle, square, rectangle, pillar, and tube in any simulation software.
20 February 2021 1,750 1 View
I am using qualitative research to look at employee motivation. I will use a closed and open ended survey (for biodata information and general views to motivation) and semi structured interviews...
18 February 2021 436 11 View
Hello all, as I understand there isn't any straight way to get an rdf of atoms from the center of mass or a coordinate of specific atoms in lammps. I wonder if anyone know any trick or way to get...
16 February 2021 2,517 2 View
The final qualification assessment for major programs is a strict regimen that involves different stages - oral and written exams, final project viva, internal and external review. How are ICT...
16 February 2021 1,762 8 View
All, I am trying to equilibrate an Ice 1h crystalline structure to 250K in LAMMPS. When I tried to do this at 250K directly, the structure lost it's crystalline shape and became disordered post...
14 February 2021 5,747 2 View