Skip to content

Commit

Permalink
Rename variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuel Carrer committed Oct 12, 2021
1 parent 5b2884b commit cac1734
Showing 1 changed file with 20 additions and 50 deletions.
70 changes: 20 additions & 50 deletions hymd/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ def add_forces():
dipole_positions = np.zeros(shape=(4, 3), dtype=dtype)
dipole_forces = np.zeros(shape=(4, 3))
dipole_charges = np.zeros(shape=4)
trans_matrices = np.zeros(shape=(6, 3, 3), dtype=dtype)
transfer_matrices = np.zeros(shape=(6, 3, 3), dtype=dtype)

# Initialize energies
field_energy = 0.0
Expand Down Expand Up @@ -631,7 +631,7 @@ def add_forces():
dtype=dtype,
).flatten()
dipole_forces = np.zeros_like(dipole_positions)
trans_matrices = np.zeros(shape=(n_tors, 6, 3, 3), dtype=dtype)
transfer_matrices = np.zeros(shape=(n_tors, 6, 3, 3), dtype=dtype)
# Fields
phi_dipoles = pm.create("real", value=0.0)
phi_dipoles_fourier = pm.create("complex", value=0.0)
Expand All @@ -648,7 +648,7 @@ def add_forces():
angle_forces = np.asfortranarray(angle_forces)
dihedral_forces = np.asfortranarray(dihedral_forces)
dipole_positions = np.asfortranarray(dipole_positions)
trans_matrices = np.asfortranarray(trans_matrices)
transfer_matrices = np.asfortranarray(transfer_matrices)

if not args.disable_bonds:
bond_energy_ = compute_bond_forces(
Expand Down Expand Up @@ -680,7 +680,7 @@ def add_forces():
dihedral_forces,
positions,
dipole_positions,
trans_matrices,
transfer_matrices,
config.box_size,
bonds_4_atom1,
bonds_4_atom2,
Expand Down Expand Up @@ -718,7 +718,7 @@ def add_forces():
dipole_forces_redistribution(
reconstructed_forces,
dipole_forces,
trans_matrices,
transfer_matrices,
bonds_4_atom1,
bonds_4_atom2,
bonds_4_atom3,
Expand Down Expand Up @@ -752,7 +752,7 @@ def add_forces():
bonds_2_atom2,
velocity_out=args.velocity_output,
force_out=args.force_output,
charge_out=charges_flag,
charges=charges if charges_flag else False,
comm=comm,
)

Expand Down Expand Up @@ -910,7 +910,7 @@ def add_forces():
dihedral_forces,
positions,
dipole_positions,
trans_matrices,
transfer_matrices,
config.box_size,
bonds_4_atom1,
bonds_4_atom2,
Expand Down Expand Up @@ -951,7 +951,7 @@ def add_forces():
)

## add q related
if charges_flag:
if charges_flag and config.coulombtype == "PIC_Spectral":
layout_q = pm.decompose(positions)
### split
update_field_force_q(
Expand Down Expand Up @@ -1000,7 +1000,7 @@ def add_forces():
dipole_forces_redistribution(
reconstructed_forces,
dipole_forces,
trans_matrices,
transfer_matrices,
bonds_4_atom1,
bonds_4_atom2,
bonds_4_atom3,
Expand Down Expand Up @@ -1054,10 +1054,14 @@ def add_forces():
types,
]

if charges_flag: ## add charge related
args_in.append(charges)
args_in.append(elec_forces)

dd = domain_decomposition(
positions,
pm,
*args_in,
*tuple(args_in),
molecules=molecules if molecules_flag else None,
bonds=bonds if molecules_flag else None,
verbose=args.verbose,
Expand Down Expand Up @@ -1118,9 +1122,11 @@ def add_forces():
dtype=dtype,
).flatten()
dipole_forces = np.zeros_like(dipole_positions)
trans_matrices = np.zeros(shape=(n_tors, 6, 3, 3), dtype=dtype)
transfer_matrices = np.zeros(
shape=(n_tors, 6, 3, 3), dtype=dtype
)
dipole_positions = np.asfortranarray(dipole_positions)
trans_matrices = np.asfortranarray(trans_matrices)
transfer_matrices = np.asfortranarray(transfer_matrices)

for t in range(config.n_types):
if args.verbose > 2:
Expand Down Expand Up @@ -1165,7 +1171,7 @@ def add_forces():
comm=comm,
)

if charges_flag:
if charges_flag and config.coulombtype == "PIC_Spectral":
field_q_energy = compute_field_energy_q(
config,
phi_q_fourier,
Expand Down Expand Up @@ -1252,7 +1258,7 @@ def add_forces():
)

## add q related
if charges_flag:
if charges_flag and config.coulombtype == "PIC_Spectral":
layout_q = pm.decompose(positions)
### split
update_field_force_q(
Expand All @@ -1276,42 +1282,6 @@ def add_forces():
comm=comm,
)

# Does this part also need to be here?
# if protein_flag:
# dipole_positions = np.reshape(
# dipole_positions, (4 * n_tors, 3), order="C"
# )
# dipole_forces = np.reshape(dipole_forces, (4 * n_tors, 3))
#
# layout_dipoles = pm.decompose(dipole_positions)
# update_field_force_q(
# dipole_charges,
# phi_dipoles,
# phi_dipoles_fourier,
# dipoles_field_fourier,
# dipoles_field,
# dipole_forces,
# layout_dipoles,
# pm,
# dipole_positions,
# config,
# )
#
# dipole_positions = np.reshape(
# dipole_positions, (n_tors, 4, 3), order="F"
# )
# dipole_forces = np.reshape(dipole_forces, (n_tors, 4, 3))
# dipole_forces_redistribution(
# reconstructed_forces,
# dipole_forces,
# trans_matrices,
# bonds_4_atom1,
# bonds_4_atom2,
# bonds_4_atom3,
# bonds_4_atom4,
# bonds_4_type,
# bonds_4_last,
# )
else:
kinetic_energy = comm.allreduce(0.5 * config.mass * np.sum(velocities ** 2))
frame = (step + 1) // config.n_print
Expand Down

0 comments on commit cac1734

Please sign in to comment.