openmm / openmm

OpenMM is a toolkit for molecular simulation using high performance GPU code.
1.51k stars 526 forks source link

Add example c++ application that runs MD from XML files #467

Open rmcgibbo opened 10 years ago

rmcgibbo commented 10 years ago

There are a variety of settings in which it would be convenient to have a minimal C++ command line application that does basically the following:

system = XmlSerializer.deserialize(sys.argv[1])
integrator = XmlSerializer.deserialize(sys.argv[2])
sim = Simulation(system, integrator)
sim.context.setState(open(sys.argv[3]).read())
sim.reporters.add(DCDReporter(...))
sim.step(...)

One of them would be for running OpenMM on weird machines like Cray where you don't want to use a python interpreter, and another would just be as an example of "full stack" usage of the OpenMM C++ API.

Do people think this would be useful? I could add this to the examples/ directory, but it might be too complex? I could also just create a separate github project.

cc: @pgrinaway

VijayPande commented 10 years ago

I think this would be useful. If we push PDBFixer as a prep tool (and have it output serialized files), this could work really well.

rmcgibbo commented 10 years ago

Presupposing an answer in the affirmative, a related question is "should this program be built and installed when you run cmake; make; make install, or is this just an example program?"

peastman commented 10 years ago

This would make a nice example. I'm not sure how useful it would be as a standalone application. There's enough variation in the details of how people run simulations that it would either have to be 1) quite large and complicated, with lots of command line options, or 2) intended for people to customize before using. The latter is much easier for us to write, more flexible, and probably just as useful.

rmcgibbo commented 10 years ago

@VijayPande: PDBFixer doesn't have an interface for you to select things like the integrator and forcefield though, so it's not really a full prep tool for serialized OpenMM files. But this would be very much within the scope of an expanded version of http://builder.openmm.org/. Currently it uses all your selections to define a python script, but it could have a mode in which it outputed the serialized files I think.

proteneer commented 10 years ago

+1 - wouldn't be hard. I also recommend running the resulting app through valgrind to make sure there's no memory leaks. (Though that will be hard - I've spent the past 3 hours trying to hunt down a memory leak, or two)

On Thu, May 29, 2014 at 2:55 PM, Robert McGibbon notifications@github.com wrote:

@VijayPande https://github.com/VijayPande: PDBFixer doesn't have an interface for you to select things like the integrator and forcefield though, so it's not really a full prep tool for serialized OpenMM files. But this would be very much within the scope of an expanded version of http://builder.openmm.org/. Currently it uses all your selections to define a python script, but it could have a mode in which it outputed the serialized files I think.

— Reply to this email directly or view it on GitHub https://github.com/SimTk/openmm/issues/467#issuecomment-44590631.

Yutong Zhao Stanford University

www.proteneer.com | simbios.stanford.edu

rmcgibbo commented 10 years ago

@peastman: yeah, I'm not sure exactly how many options are worth adding here. There is definitely a balance to be struck between making it useful as a teaching example and making a full fledged useful CLI, and I'm not totally sure if it's possible to have something in the middle that bridges both use cases, or if it's the case that anything simple enough to be a good example would be not full featured enough to be "useful" for production and visa verse. Maybe I'll just implement it and see if such a balance is even possible.

rmcgibbo commented 10 years ago

I started working on this a little here: https://github.com/rmcgibbo/openmm/tree/cli/examples/cli

danielhollas commented 7 years ago

Sorry for commenting on the old issue, but did you ever worked out such an example?

I was actually just thinking how to create a system from PDB file and XML force field in C++ API. Looking at the C++ API documentation did not help me much, having even the most simple example would be quite helpful.

rmcgibbo commented 7 years ago

I did not. And I seem to have lost that branch.

mpharrigan commented 7 years ago

I think the forcefield creation stuff is all within python. You can use a python script to serialize system, integrator, and state to xml files which can be loaded and run using just the cpp api. You can check out fahbench https://github.com/fahbench/fahbench for an example of running from these xml files