More GALAMOST tutorials and examples are available from

The C++ and CUDA C code has been written as an extended module of Python. We can use the functions of GALAMOST by loading and calling its modules through a Python script. With the prepared script, you should now be able to try running GALAMOST as:


./yourscript.gala --gpu=0 >a.log&

Where you may specify the GPU id with the --gpu= option and output the screen information into a.log file. If the script file has no executive permission, the command of chmod +x yourscript.gala should be executed before running above command. An alternative running command which could ignore the executive permission of the script:


python yourscript.gala --gpu=0 >a.log&

For version 4, you could use multiple GPU for parallel computation by following commands:


mpirun -n 4 python yourscript.gala --gpu=0,1,2,3 >a.log&

Here is an example of script for DPD simulation. The head of GALAMOST script usually is:


import sys
import galamost

global _options
parser = OptionParser()
parser.add_option('--gpu', dest='gpu',help='GPU on which to execute')
(_options, args) = parser.parse_args()

where the first paragraph sets the path of the installed library of GALAMOST for loading the Python extensible modules of GALAMOST. The second paragraph is used for parsing GPU id from the executive command.

Then, reading the configuration from a prepared XML file by XmlReader and building up perform configuration of GPU by PerformConfig, a system information (AllInfo) can be built up by


filename = 'A.xml'
build_method = galamost.XmlReader(filename)
perform_config = galamost.PerformConfig(_options.gpu)
all_info = galamost.AllInfo(build_method,perform_config)

After that, we need to build up an application with Application which will call following defined and added objects.


dt = 0.01
app = galamost.Application(all_info, dt)

Further, we should define the wanted objects by the classes of GALAMOST and pass them to the application, such as the following example: non-bonded DPD force (DpdForce), NVT thermostat with GWVV algorithm (DpdGwvv), and information analysis methods (ComputeInfo).


neighbor_list = galamost.NeighborList(all_info, 1.0 ,0.05) # (,rcut,rbuffer)
dpd=galamost.DpdForce(all_info,neighbor_list,1.0, 12345) # (,,rcut,seed)
dpd.setParams('A', 'A', 25.0, 3.0) # (type1, type2, alpha, sigma)
dpd.setParams('A', 'B', 40.0, 3.0) # (type1, type2, alpha, sigma)
dpd.setParams('B', 'B', 25.0, 3.0) # (type1, type2, alpha, sigma)

group = galamost.ParticleSet(all_info, "all" )
comp_info = galamost.ComputeInfo(all_info, group)
Gwvv = galamost.DpdGwvv(all_info, group)

dinfo = galamost.DumpInfo(all_info, comp_info, 'data.log')

The tail of script usually sets the number of time steps to run, and the function of analysis of neighbor list (NeighborList) etc.

Examples: 10000)