hoomd-examples icon indicating copy to clipboard operation
hoomd-examples copied to clipboard

Patchy Particles example does not work with hooomd 4.6.0

Open JonathanH12 opened this issue 2 months ago • 3 comments

File name

02-Simulating-a-System-of-Patchy-Particles.ipynb

Description

Running this notebook, both within jupyter and as a python script, results in the following error

(base) Patron@Patrons-MacBook-Air ~ % python 02-Simulating-a-System-of-Patchy-Particles.py
/Users/Patron/02-Simulating-a-System-of-Patchy-Particles.py:237: FutureWarning: CPPPotential is deprecated since 4.6.0. Use a hpmc.pair.Pair potential.
  patch_potential = hoomd.hpmc.pair.user.CPPPotential(
/Users/Patron/02-Simulating-a-System-of-Patchy-Particles.py:247: FutureWarning: pair_potential is deprecated since 4.5.0. Use pair_potentials.
  mc.pair_potential = patch_potential
Traceback (most recent call last):
  File "/Users/Patron/02-Simulating-a-System-of-Patchy-Particles.py", line 256, in <module>
    simulation.run(0)
  File "/opt/anaconda3/lib/python3.11/site-packages/hoomd/simulation.py", line 555, in run
    self.operations._schedule()
  File "/opt/anaconda3/lib/python3.11/site-packages/hoomd/operations.py", line 211, in _schedule
    self.integrator._attach(sim)
  File "/opt/anaconda3/lib/python3.11/site-packages/hoomd/operation.py", line 315, in _attach
    self._attach_hook()
  File "/opt/anaconda3/lib/python3.11/site-packages/hoomd/hpmc/integrate.py", line 457, in _attach_hook
    self._pair_potential._attach(self._simulation)
  File "/opt/anaconda3/lib/python3.11/site-packages/hoomd/operation.py", line 315, in _attach
    self._attach_hook()
  File "/opt/anaconda3/lib/python3.11/site-packages/hoomd/hpmc/pair/user.py", line 290, in _attach_hook
    self._cpp_obj = _jit.PatchEnergyJIT(
                    ^^^^^^^^^^^^^^^^^^^^
RuntimeError: Error compiling JIT code:

                        #include <stdio.h>
                        #include "hoomd/HOOMDMath.h"
                        #include "hoomd/VectorMath.h"

                        // param_array (singlet class) or param_array_isotropic
                        // and param_array_constituent (union class) are
                        // allocated by the library
                        float *param_array;
                        

                        using namespace hoomd;

                        extern "C"
                        {
                        float eval(const vec3<float>& r_ij,
                            unsigned int type_i,
                            const quat<float>& q_i,
                            float d_i,
                            float charge_i,
                            unsigned int type_j,
                            const quat<float>& q_j,
                            float d_j,
                            float charge_j)
                            {
                        
const float delta = 45 * M_PI / 180;  // delta in radians
const float epsilon = 1.000000;
const float lambda = 1.200000;
const float sigma = 1.000000;  // hard core diameter

const float kT = param_array[0];
const float beta_epsilon = epsilon/kT;

const vec3<float> ehat_particle_reference_frame(1, 0, 0);
vec3<float> ehat_i = rotate(q_i, ehat_particle_reference_frame);
vec3<float> ehat_j = rotate(q_j, ehat_particle_reference_frame);

vec3<float> r_hat_ij = r_ij / sqrtf(dot(r_ij, r_ij));
bool patch_on_i_is_aligned_with_r_ij = dot(ehat_i, r_hat_ij) >= cos(delta);
bool patch_on_j_is_aligned_with_r_ji = dot(ehat_j, -r_hat_ij) >= cos(delta);

float rsq = dot(r_ij, r_ij);
float r_ij_length = sqrtf(rsq);
if (patch_on_i_is_aligned_with_r_ij
    && patch_on_j_is_aligned_with_r_ji
    && r_ij_length < lambda*sigma)
    {
    return -beta_epsilon;
    }
else
    {
    return 0.0;
    }

                            }
                        }
                        
Compilation arguments:
-cc1
-triple
x86_64-apple-macosx13.0.0
-Wundef-prefix=TARGET_OS_OSX
-Werror=undef-prefix
-Wdeprecated-objc-isa-usage
-Werror=deprecated-objc-isa-usage
-emit-llvm
-disable-free
-clear-ast-before-backend
-disable-llvm-verifier
-discard-value-names
-main-file-name
_hoomd_llvm_code.cc
-mrelocation-model
pic
-pic-level
2
-mframe-pointer=all
-ffp-contract=on
-fno-rounding-math
-funwind-tables=2
-fcompatibility-qualified-id-block-type-checking
-fvisibility-inlines-hidden-static-local-var
-target-cpu
penryn
-tune-cpu
generic
-mllvm
-treat-scalable-fixed-error-as-warning
-debugger-tuning=lldb
-target-linker-version
609
-fcoverage-compilation-dir=/Users/Patron
-resource-dir
/opt/anaconda3/lib/clang/14.0.6
-D
HOOMD_LLVMJIT_BUILD
-D
HOOMD_LONGREAL_SIZE=64
-D
HOOMD_SHORTREAL_SIZE=32
-I
/opt/anaconda3/lib/python3.11/site-packages/hoomd/include
-stdlib=libc++
-internal-isystem
/opt/anaconda3/bin/../include/c++/v1
-internal-isystem
/usr/local/include
-internal-isystem
/opt/anaconda3/lib/clang/14.0.6/include
-internal-externc-isystem
/usr/include
-O3
--std=c++14
-fdeprecated-macro
-fdebug-compilation-dir=/Users/Patron
-ferror-limit
19
-stack-protector
1
-fblocks
-fencode-extended-block-signature
-fregister-global-dtors-with-atexit
-fgnuc-version=4.2.1
-fcxx-exceptions
-fexceptions
-fmax-type-align=16
-vectorize-loops
-vectorize-slp
-D__GCC_HAVE_DWARF2_CFI_ASM=1
-o
_hoomd_llvm_code.ll
-x
c++
_hoomd_llvm_code.cc

In file included from code.cc:3:
In file included from /opt/anaconda3/lib/python3.11/site-packages/hoomd/include/hoomd/HOOMDMath.h:33:
In file included from /opt/anaconda3/bin/../include/c++/v1/cmath:317:
In file included from /opt/anaconda3/bin/../include/c++/v1/math.h:316:
/opt/anaconda3/bin/../include/c++/v1/stdlib.h:150:34: error: unknown type name 'ldiv_t'
inline _LIBCPP_INLINE_VISIBILITY ldiv_t div(long __x, long __y) _NOEXCEPT {
                                 ^
/opt/anaconda3/bin/../include/c++/v1/stdlib.h:151:12: error: no member named 'ldiv' in the global namespace
  return ::ldiv(__x, __y);
         ~~^
/opt/anaconda3/bin/../include/c++/v1/stdlib.h:154:34: error: unknown type name 'lldiv_t'
inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x,
                                 ^
/opt/anaconda3/bin/../include/c++/v1/stdlib.h:156:12: error: no member named 'lldiv' in the global namespace
  return ::lldiv(__x, __y);
         ~~^
In file included from code.cc:3:
In file included from /opt/anaconda3/lib/python3.11/site-packages/hoomd/include/hoomd/HOOMDMath.h:33:
In file included from /opt/anaconda3/bin/../include/c++/v1/cmath:317:
/opt/anaconda3/bin/../include/c++/v1/math.h:388:31: error: use of undeclared identifier 'FP_NAN'
  return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
                              ^
/opt/anaconda3/bin/../include/c++/v1/math.h:388:39: error: use of undeclared identifier 'FP_INFINITE'
  return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
                                      ^
/opt/anaconda3/bin/../include/c++/v1/math.h:388:52: error: use of undeclared identifier 'FP_NORMAL'
  return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
                                                   ^
/opt/anaconda3/bin/../include/c++/v1/math.h:388:63: error: use of undeclared identifier 'FP_SUBNORMAL'
  return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
                                                              ^
/opt/anaconda3/bin/../include/c++/v1/math.h:388:77: error: use of undeclared identifier 'FP_ZERO'
  return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
                                                                            ^
/opt/anaconda3/bin/../include/c++/v1/math.h:393:21: error: use of undeclared identifier 'FP_ZERO'
  return __x == 0 ? FP_ZERO : FP_NORMAL;
                    ^
/opt/anaconda3/bin/../include/c++/v1/math.h:393:31: error: use of undeclared identifier 'FP_NORMAL'
  return __x == 0 ? FP_ZERO : FP_NORMAL;
                              ^
In file included from code.cc:3:
/opt/anaconda3/lib/python3.11/site-packages/hoomd/include/hoomd/HOOMDMath.h:249:21: error: no member named 'sqrtf' in the global namespace; did you mean 'sqrt'?
    return 1.0f / ::sqrtf(x);
                  ~~^~~~~
                    sqrt
/opt/anaconda3/bin/../include/c++/v1/math.h:929:42: note: 'sqrt' declared here
inline _LIBCPP_HIDE_FROM_ABI float       sqrt(float __x) _NOEXCEPT       {return __builtin_sqrtf(__x);}
                                         ^
In file included from code.cc:3:
/opt/anaconda3/lib/python3.11/site-packages/hoomd/include/hoomd/HOOMDMath.h:269:14: error: no member named 'sinf' in the global namespace
    return ::sinf(x);
           ~~^
/opt/anaconda3/lib/python3.11/site-packages/hoomd/include/hoomd/HOOMDMath.h:285:14: error: no member named 'cosf' in the global namespace
    return ::cosf(x);
           ~~^
/opt/anaconda3/lib/python3.11/site-packages/hoomd/include/hoomd/HOOMDMath.h:299:5: error: use of undeclared identifier '__sincosf'; did you mean 'sincos'?
    __sincosf(x, &s, &c);
    ^~~~~~~~~
    sincos
/opt/anaconda3/lib/python3.11/site-packages/hoomd/include/hoomd/HOOMDMath.h:296:24: note: 'sincos' declared here
inline HOSTDEVICE void sincos(float x, float& s, float& c)
                       ^
/opt/anaconda3/lib/python3.11/site-packages/hoomd/include/hoomd/HOOMDMath.h:299:18: error: non-const lvalue reference to type 'float' cannot bind to a temporary of type 'float *'
    __sincosf(x, &s, &c);
                 ^~
/opt/anaconda3/lib/python3.11/site-packages/hoomd/include/hoomd/HOOMDMath.h:296:47: note: passing argument to parameter 's' here
inline HOSTDEVICE void sincos(float x, float& s, float& c)
                                              ^
/opt/anaconda3/lib/python3.11/site-packages/hoomd/include/hoomd/HOOMDMath.h:311:7: error: no member named '__sincos' in the global namespace
    ::__sincos(x, &s, &c);
    ~~^
/opt/anaconda3/lib/python3.11/site-packages/hoomd/include/hoomd/HOOMDMath.h:323:5: error: use of undeclared identifier '__sincospif'; did you mean 'sincospi'?
    __sincospif(x, &s, &c);
    ^~~~~~~~~~~
    sincospi
/opt/anaconda3/lib/python3.11/site-packages/hoomd/include/hoomd/HOOMDMath.h:318:24: note: 'sincospi' declared here
inline HOSTDEVICE void sincospi(float x, float& s, float& c)
                       ^
/opt/anaconda3/lib/python3.11/site-packages/hoomd/include/hoomd/HOOMDMath.h:323:20: error: non-const lvalue reference to type 'float' cannot bind to a temporary of type 'float *'
    __sincospif(x, &s, &c);
                   ^~
/opt/anaconda3/lib/python3.11/site-packages/hoomd/include/hoomd/HOOMDMath.h:318:49: note: passing argument to parameter 's' here
inline HOSTDEVICE void sincospi(float x, float& s, float& c)
                                                ^
fatal error: too many errors emitted, stopping now
Error generating code.
20 errors generated.

Can you fix it?

We have been unable to fix it.

JonathanH12 avatar Apr 30 '24 19:04 JonathanH12