Acessing the function of source file (C++) in the python script

28 views
Skip to first unread message

Avishek Kumar

unread,
Nov 9, 2023, 12:26:19 AM11/9/23
to hoomd-users
Hi,

Is there a possibility of accessing the function introduced in source file (C++) via python script. Earlier in HOOMD v2.7.0, I had introduced some function in Neighbourlist.cc Code and accordingly made changes in Neighbourlist.h file, which was successfully built. Now using python script, I was able to initialize the variable of the function (through cpp_nlist). For example I was doing something like this:

nl_functional=hoomd.md.nlist.tree(r_buff=0.0)
nl_functional.cpp_nlist.arbitaryFunction(...)

The arbitaryFunction() is declared in Neighbourlist.cc file. The main objective of doing this is to modify the neighbourlist array within the simulation, i.e., h_nlist array. 

Can we do something like this in HOOMD v4.1.0. Please guide me.

Regards,
Avishek

Joshua Anderson

unread,
Nov 9, 2023, 3:17:01 PM11/9/23
to hoomd...@googlegroups.com
Avishek,

Anything is possible. You might start by reviewing the ARCHITECTURE.md file which documents the code architecture, or by looking at some of the Python code in HOOMD.
------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan

--
You received this message because you are subscribed to the Google Groups "hoomd-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hoomd-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hoomd-users/131e7440-6f5d-4309-bf69-6cdc424d1ce9n%40googlegroups.com.

Avishek Kumar Avishek Kumar

unread,
Nov 9, 2023, 3:24:44 PM11/9/23
to hoomd...@googlegroups.com
Thanks Joshua for helping me. But could you help me in understanding how I should proceed in calling some arbitrary C++ function within the source code through a Python script? A small guidance might help me in understanding.

Is there some way of modifying the neighbor list array in HOOMD4 in between the simulation? 

Regards, 
Avishek



--
Avishek Kumar
PhD Scholar,
IITB-Monash Research Academy.

Joshua Anderson

unread,
Nov 10, 2023, 4:09:06 PM11/10/23
to hoomd...@googlegroups.com
Avishek,

Please read the **extensive** documentation that we have provided in ARCHITECTURE.md and in the docstrings of all the Python classes.

------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan
Reply all
Reply to author
Forward
0 new messages