Skip to content

Commit

Permalink
Minor changes to decrease validation time in top compatibility during…
Browse files Browse the repository at this point in the history
… checking
  • Loading branch information
CalCraven committed Jan 15, 2024
1 parent dd6f910 commit 8b82583
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions gmso/utils/compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def check_compatibility(topology, accepted_potentials):
"""
potential_forms_dict = dict()
for atom_type in topology.atom_types(
filter_by=PotentialFilters.UNIQUE_NAME_CLASS
filter_by=PotentialFilters.UNIQUE_EXPRESSION
):
potential_form = _check_single_potential(
atom_type,
Expand All @@ -43,7 +43,7 @@ def check_compatibility(topology, accepted_potentials):
potential_forms_dict.update(potential_form)

for connection_type in topology.connection_types(
# filter_by=PotentialFilters.UNIQUE_NAME_CLASS
filter_by=PotentialFilters.UNIQUE_EXPRESSION
):
potential_form = _check_single_potential(
connection_type,
Expand Down
5 changes: 4 additions & 1 deletion gmso/utils/conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from functools import lru_cache

import numpy as np
import symengine
import sympy
import unyt as u
from unyt.dimensions import length, mass, time
Expand All @@ -20,7 +21,8 @@ def _constant_multiplier(pot1, pot2):
# TODO: Test outputs
# TODO: Check speed
try:
constant = sympy.simplify(pot1.expression / pot2.expression)
constant = symengine.expand(pot1.expression / pot2.expression)
# constant = sympy.simplify(pot1.expression / pot2.expression)
if constant.is_number:
for eq_term in pot1.expression.args:
if eq_term.is_symbol:
Expand All @@ -35,6 +37,7 @@ def _constant_multiplier(pot1, pot2):
sympy_conversionsList = [_constant_multiplier]


@lru_cache(maxsize=128)
def _try_sympy_conversions(pot1, pot2):
# TODO: Doc string
# TODO: Test outputs
Expand Down

0 comments on commit 8b82583

Please sign in to comment.