I did MD simulation of polymer-drug in water environment. I need to calculate the octanol-water partition coefficient. How to do that using gromacs? Is a direct tool or modules such as gmx rdf or gmx energy for this aim?
No, there are not “ready-made” tools within GROMACS, as far as I know. The calculations itself is far from trivial and depends on what approach you want to use.
The octanol-water partition can be calculated with different tools, some are based on predictions inferred from taking properties of the molecule and comparing with a database of already known ones, other are based on DFT calculations and statistical mechanics (e.g. COSMO-RS), here you find a discussion on some of them, but there are many more methods around.
If you want to calculate the octanol/water partition coefficient via MD sims there are different approaches, you can see a few examples here and here.
Specifically, within GROMACS, I would say that arguably the best starting point to understand a bit better the process to follow to implement ONE of the possible ways to calculate the logP is this suite of tutorials, and this one in particular.