def find_dynamicsymbols(expression, exclude=None):
    t_set = {dynamicsymbols._t}
    if exclude:
        if iterable(exclude):
            exclude_set = set(exclude)
        else:
            raise TypeError("exclude kwarg must be iterable")
    else:
        exclude_set = set()
    return set([i for i in expression.atoms(AppliedUndef, Derivative) if
            i.free_symbols == t_set]) - exclude_set
Find all dynamicsymbols in expression.
dataset/ETHPy150Open sympy/sympy/sympy/physics/mechanics/functions.py/find_dynamicsymbols