Commit c1a5772d authored by eric pellegrini's avatar eric pellegrini

Fixed many many many bugs due to the protage of nmoldyn to MDANSE.

Reduced the size of PDB example file.
Added the generated functional tests for all MDANSE analysis.
Bug fix in spatial density cython file
parent 8d3fb9a6
MOLECULAR_CONTENTS
2
ETHYNE
C1 C
C2 C
H2 H
H2 H
WATER
O1 O
H1 H
H2 H
MOLECULES
ETHYNE 1
WATER 2
NFRAMES
4
FRAMETIME
1.5
BOX_COORDINATES
False
CELL
10,0,0
0,10,0
0,0,10
10,0,0
0,10,0
0,0,10
10,0,0
0,10,0
0,0,10
10,0,0
0,10,0
0,0,10
CONFIGURATION
0,0,0
0,0,1
0,1,0
0,1,1
1,0,0
1,0,1
1,1,0
1,1,1
2,2,2
3,3,3
0,0,0
0,0,1
0,1,0
0,1,1
1,0,0
1,0,1
1,1,0
1,1,1
2,2,2
3,3,3
0,0,0
0,0,1
0,1,0
0,1,1
1,0,0
1,0,1
1,1,0
1,1,1
2,2,2
3,3,3
0,0,0
0,0,1
0,1,0
0,1,1
1,0,0
1,0,1
1,1,0
1,1,1
2,2,2
3,3,3
This diff is collapsed.
......@@ -35,10 +35,9 @@ def spatial_density(ndarray[np.float64_t, ndim=2] config not None,
cdef double x, y, z, sdx, sdy, sdz, minix, miniy, miniz
cdef double xorigin, yorigin, zorigin, orthx, orthy, orthz
cdef double aa, bb, cc, dd, ee, ff, gg, hh, ii, denum, micx, micy, micz, xscaledOrigin, yscaledOrigin, zscaledOrigin
cdef double aa, bb, cc, dd, ee, ff, gg, hh, ii, denum, micx, micy, micz, xscaledOrigin, yscaledOrigin, zscaledOrigin, xscaledMin, yscaledMin, zscaledMin
cdef int i, j,k, bin, nbins, nbases, nindexes, xind, yind, zind
nbases = bases.shape[0]
nindexes = indexes.shape[0]
......@@ -49,7 +48,7 @@ def spatial_density(ndarray[np.float64_t, ndim=2] config not None,
cdef ndarray[np.float64_t, ndim=2] invBasis = np.zeros((3,3), dtype = np.float64)
cdef ndarray[np.float64_t, ndim=2] basis = np.zeros((3,3), dtype = np.float64)
cdef ndarray[np.float64_t, ndim=2] scaleconfig = np.zeros((nindexes,3), dtype = np.float64)
for 0 <= i < nindexes:
x = <float> config[i,0]
......@@ -72,33 +71,36 @@ def spatial_density(ndarray[np.float64_t, ndim=2] config not None,
basis = bases[i,:,:]
aa = <float>basis[0,0]
bb = <float>basis[0,1]
cc = <float>basis[0,2]
dd = <float>basis[1,0]
ee = <float>basis[1,1]
ff = <float>basis[1,2]
gg = <float>basis[2,0]
hh = <float>basis[2,1]
ii = <float>basis[2,2]
denum = -cc*ee*gg+bb*ff*gg+cc*dd*hh-aa*ff*hh-bb*dd*ii+aa*ee*ii
invBasis[0,0] = (-ff*hh+ee*ii)/denum
invBasis[0,1] = (cc*hh-bb*ii)/denum
invBasis[0,2] = (-cc*ee+bb*ff)/denum
invBasis[1,0] = (ff*gg-dd*ii)/denum
invBasis[1,1] = (-cc*gg+aa*ii)/denum
invBasis[1,2] = (cc*dd-aa*ff)/denum
invBasis[2,0] = (-ee*gg+dd*hh)/denum
invBasis[2,1] = (bb*gg-aa*hh)/denum
invBasis[2,2] = (-bb*dd+aa*ee)/denum
m00 = <float>basis[0,0]
m01 = <float>basis[0,1]
m02 = <float>basis[0,2]
m10 = <float>basis[1,0]
m11 = <float>basis[1,1]
m12 = <float>basis[1,2]
m20 = <float>basis[2,0]
m21 = <float>basis[2,1]
m22 = <float>basis[2,2]
denum = -m02*m11*m20 + m01*m12*m20 + m02*m10*m21 - m00*m12*m21- m01*m10*m22 + m00*m11*m22
invBasis[0,0] = (-m12*m21+m11*m22)/denum
invBasis[0,1] = ( m02*m21-m01*m22)/denum
invBasis[0,2] = (-m02*m11+m01*m12)/denum
invBasis[1,0] = ( m12*m20-m10*m22)/denum
invBasis[1,1] = (-m02*m20+m00*m22)/denum
invBasis[1,2] = ( m02*m10-m00*m12)/denum
invBasis[2,0] = (-m11*m20+m10*m21)/denum
invBasis[2,1] = ( m02*m20-m00*m21)/denum
invBasis[2,2] = (-m02*m10+m00*m11)/denum
xscaledMin = <float> (invBasis[0,0]*minix + invBasis[0,1]*miniy + invBasis[0,2]*miniz)
yscaledMin = <float> (invBasis[1,0]*minix + invBasis[1,1]*miniy + invBasis[1,2]*miniz)
zscaledMin = <float> (invBasis[2,0]*minix + invBasis[2,1]*miniy + invBasis[2,2]*miniz)
for 0 <= j < nindexes:
sdx = scaleconfig[j,0] - xscaledOrigin
......@@ -113,23 +115,18 @@ def spatial_density(ndarray[np.float64_t, ndim=2] config not None,
micy = sdx*cell[1,0] + sdy*cell[1,1] + sdz*cell[1,2]
micz = sdx*cell[2,0] + sdy*cell[2,1] + sdz*cell[2,2]
orthx = <float> (invBasis[0,0]*micx + invBasis[0,1]*micy + invBasis[0,2]*micz)
orthy = <float> (invBasis[1,0]*micx + invBasis[1,1]*micy + invBasis[1,2]*micz)
orthz = <float> (invBasis[2,0]*micx + invBasis[2,1]*micy + invBasis[2,2]*micz)
orthx = <float> (invBasis[0,0]*micx + invBasis[0,1]*micy + invBasis[0,2]*micz)
orthy = <float> (invBasis[1,0]*micx + invBasis[1,1]*micy + invBasis[1,2]*micz)
orthz = <float> (invBasis[2,0]*micx + invBasis[2,1]*micy + invBasis[2,2]*micz)
x = (orthx-minix)/resolution
y = (orthy-miniy)/resolution
z = (orthz-miniz)/resolution
x = (orthx-xscaledMin)/resolution
y = (orthy-yscaledMin)/resolution
z = (orthz-zscaledMin)/resolution
xind = <int> x
yind = <int> y
zind = <int> z
hist[xind,yind,zind] += 1
return hist
\ No newline at end of file
return hist
\ No newline at end of file
......@@ -27,7 +27,7 @@
'''
Created on Apr 10, 2015
@author: Gael Goret, Eric C. Pellegrini
@author: Gael Goret and Eric C. Pellegrini
'''
import collections
......@@ -444,7 +444,7 @@ class PlotterFrame(wx.Frame):
data = collections.OrderedDict()
for k in _vars:
data[k]={}
if hasattr(vars[k], 'axis'):
if hasattr(_vars[k], 'axis'):
if _vars[k].axis:
data[k]['axis'] = _vars[k].axis.split('|')
else:
......
......@@ -97,6 +97,17 @@ class Configurable(object):
if isinstance(settings,dict):
cls.settings.update(settings)
@property
def configuration(self):
'''
Return the configuration bound to the Configurable object.
:return: the configuration bound to the Configurable object.
:rtype: dict
'''
return self._configuration
def setup(self,parameters):
'''
Setup the configuration according to a set of input parameters.
......
......@@ -63,7 +63,7 @@ class InstrumentResolutionConfigurator(IConfigurator):
type = "instrument_resolution"
_default = ('gaussian', {'mu': 0.0, 'sigma': 0.0001})
_default = ('gaussian', {'mu': 0.0, 'sigma': 10.0})
def configure(self, configuration, value):
'''
......@@ -129,10 +129,10 @@ You should change your resolution function settings to make it sharper.''',self)
if not self.has_key("kernel"):
return "No configured yet"
info = ["Instrument resolution kernel:" % self["kernel"]]
info = ["Instrument resolution kernel: %s" % self["kernel"]]
if self["parameters"]:
info.append("Parameters:")
for k,v in self["parameters"]:
for k,v in self["parameters"].items():
info.append("%s = %s" % (k,v))
info = "\n".join(info)
......
......@@ -50,7 +50,7 @@ class MMTKNetCDFTrajectoryConfigurator(InputFileConfigurator):
type = 'mmtk_trajectory'
_default = 'waterbox_in_periodic_universe.nc'
_default = os.path.join('..','..','..','Data','Trajectories','MMTK','waterbox_in_periodic_universe.nc')
def configure(self, configuration, value):
'''
......
#MDANSE : Molecular Dynamics Analysis for Neutron Scattering Experiments
#------------------------------------------------------------------------------------------
#Copyright (C)
#2015- Eric C. Pellegrini Institut Laue-Langevin
#BP 156
#6, rue Jules Horowitz
#38042 Grenoble Cedex 9
#France
#pellegrini[at]ill.fr
#goret[at]ill.fr
#aoun[at]ill.fr
#
#This library is free software; you can redistribute it and/or
#modify it under the terms of the GNU Lesser General Public
#License as published by the Free Software Foundation; either
#version 2.1 of the License, or (at your option) any later version.
#
#This library is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#Lesser General Public License for more details.
#
#You should have received a copy of the GNU Lesser General Public
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Jun 9, 2015
@author: Eric C. Pellegrini
'''
import os
from MDANSE.Framework.Configurators.IConfigurator import IConfigurator,ConfiguratorError
from MDANSE.Framework.UserDefinitionsStore import UD_STORE
class PartialChargeConfigurator(IConfigurator):
"""
This configurator allows to input partial charges.
"""
type = 'partial_charges'
_default = ''
def configure(self, configuration, value):
'''
Configure a python script.
:param configuration: the current configuration.
:type configuration: a MDANSE.Framework.Configurable.Configurable object
:param value: the path for the python script.
:type value: str
'''
trajConfig = configuration[self._dependencies['trajectory']]
if UD_STORE.has_definition(trajConfig["basename"],'partial_charges',value):
self['charges'] = UD_STORE[trajConfig["basename"],'partial_charges',value]
else:
if isinstance(value,basestring):
# Case of a python script
if os.path.exists(value):
namespace = {}
execfile(value,self.__dict__,namespace)
if not namespace.has_key('charges'):
raise ConfiguratorError("The variable 'charges' is not defined in the %r python script file" % (self["value"],))
self.update(namespace)
else:
raise ConfiguratorError("The python script defining partial charges %s could not be found." % value)
elif isinstance(value,dict):
self['charges'] = value
else:
raise ConfiguratorError("Invalid type for partial charges.")
def get_information(self):
'''
Returns some basic informations about the partial charges.
:return: the informations about the partial charges.
:rtype: str
'''
info = 'Sum of partial charges = %8.3f' % sum(self['charges'].values())
return info
......@@ -30,8 +30,6 @@ Created on Jun 9, 2015
@author: Eric C. Pellegrini
'''
from Scientific.IO.NetCDF import NetCDFFile
from MDANSE.Framework.Configurators.IConfigurator import ConfiguratorError
from MDANSE.Framework.Configurators.InputFileConfigurator import InputFileConfigurator
......
......@@ -78,22 +78,22 @@ class QVectorsConfigurator(IConfigurator):
generator, parameters = value
generator = REGISTRY["q_vectors"][generator](trajConfig["instance"])
generator.setup(parameters)
data = generator.generate()
generator.generate()
if not data:
if not generator.configuration['q_vectors']:
raise ConfiguratorError("no Q vectors could be generated", self)
self["parameters"] = parameters
self["type"] = generator.type
self["is_lattice"] = generator.is_lattice
self["q_vectors"] = generator.configuration['q_vectors']
else:
self["parameters"] = ud['parameters']
self["type"] = ud['generator']
self["is_lattice"] = ud['is_lattice']
self["q_vectors"] = ud['q_vectors']
self["parameters"] = parameters
self["type"] = generator.type
self["is_lattice"] = generator.is_lattice
self["q_vectors"] = data
self["shells"] = self["q_vectors"].keys()
self["n_shells"] = len(self["q_vectors"])
self["value"] = self["q_vectors"]
......
......@@ -201,7 +201,7 @@ class RangeConfigurator(IConfigurator):
:rtype: str
'''
info = "$d values from %s to %s" % (self['number'],self['first'],self['last'])
info = "%d values from %s to %s" % (self['number'],self['first'],self['last'])
if self._includeLast:
info += ("last value included")
......
......@@ -42,9 +42,9 @@ class GaussianInstrumentResolution(IInstrumentResolution):
type = 'gaussian'
configurators = collections.OrderedDict()
configurators['mu'] = ('float', {"default":0.0})
configurators['sigma'] = ('float', {"default":1.0})
settings = collections.OrderedDict()
settings['mu'] = ('float', {"default":0.0})
settings['sigma'] = ('float', {"default":1.0})
def set_kernel(self, frequencies, dt):
......
......@@ -42,7 +42,7 @@ class IdealInstrumentResolution(IInstrumentResolution):
type = 'ideal'
configurators = collections.OrderedDict()
settings = collections.OrderedDict()
def set_kernel(self, frequencies, dt):
......
......@@ -43,9 +43,9 @@ class LorentzianInstrumentResolution(IInstrumentResolution):
type = 'lorentzian'
configurators = collections.OrderedDict()
configurators['mu'] = ('float', {"default":0.0})
configurators['sigma'] = ('float', {"default":1.0})
settings = collections.OrderedDict()
settings['mu'] = ('float', {"default":0.0})
settings['sigma'] = ('float', {"default":1.0})
def set_kernel(self, frequencies, dt):
......
......@@ -42,12 +42,12 @@ class PseudoVoigtInstrumentResolution(IInstrumentResolution):
type = 'pseudo-voigt'
configurators = collections.OrderedDict()
configurators['eta'] = ('float', {"mini":0.0, "maxi":1.0, "default":0.5})
configurators['mu_lorentzian'] = ('float', {"default":0.0})
configurators['sigma_lorentzian'] = ('float', {"default":1.0})
configurators['mu_gaussian'] = ('float', {"default":0.0})
configurators['sigma_gaussian'] = ('float', {"default":1.0})
settings = collections.OrderedDict()
settings['eta'] = ('float', {"mini":0.0, "maxi":1.0, "default":0.5})
settings['mu_lorentzian'] = ('float', {"default":0.0})
settings['sigma_lorentzian'] = ('float', {"default":1.0})
settings['mu_gaussian'] = ('float', {"default":0.0})
settings['sigma_gaussian'] = ('float', {"default":1.0})
def set_kernel(self, frequencies, dt):
......
......@@ -42,9 +42,9 @@ class SquareInstrumentResolution(IInstrumentResolution):
type = 'square'
configurators = collections.OrderedDict()
configurators['mu'] = ('float', {"default":0.0})
configurators['sigma'] = ('float', {"default":1.0})
settings = collections.OrderedDict()
settings['mu'] = ('float', {"default":0.0})
settings['sigma'] = ('float', {"default":1.0})
def set_kernel(self, frequencies, dt):
......
......@@ -42,9 +42,9 @@ class TriangularInstrumentResolution(IInstrumentResolution):
type = 'triangular'
configurators = collections.OrderedDict()
configurators['mu'] = ('float', {"default":0.0})
configurators['sigma'] = ('float', {"default":1.0})
settings = collections.OrderedDict()
settings['mu'] = ('float', {"default":0.0})
settings['sigma'] = ('float', {"default":1.0})
def set_kernel(self, frequencies, dt):
......
......@@ -27,7 +27,7 @@
'''
Created on Apr 10, 2015
@author: pellegrini
@author: Eric C. Pellegrini
'''
import collections
......@@ -72,7 +72,8 @@ class AngularCorrelation(IJob):
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
settings['frames'] = ('frames', {"dependencies":{'trajectory':'trajectory'}})
settings['axis_selection'] = ('axis_selection',{"dependencies":{'trajectory':'trajectory'}})
settings['axis_selection'] = ('axis_selection',{"dependencies":{'trajectory':'trajectory'},
'default' : {'molecule':'Water', 'endpoint1':('OW',), 'endpoint2':('HW',)}})
settings['per_axis'] = ('boolean', {"label":"output contribution per axis", "default":False})
settings['output_files'] = ('output_files', {"formats":["netcdf","ascii"]})
settings['running_mode'] = ('running_mode',{})
......@@ -124,7 +125,7 @@ class AngularCorrelation(IJob):
diff /= modulus[:,numpy.newaxis]
ac = correlation(diff,axis=0,reduce=1)
ac = correlation(diff,axis=0,average=1)
return index, ac
......
......@@ -27,10 +27,11 @@
'''
Created on Apr 10, 2015
@author: pellegrini
@author: Bachir Aoun and Eric C. Pellegrini
'''
import collections
import os
import numpy
......@@ -58,13 +59,10 @@ class AreaPerMolecule(IJob):
ancestor = "mmtk_trajectory"
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
settings['trajectory'] = ('mmtk_trajectory',{'default':os.path.join('..','..','..','Data','Trajectories','MMTK','dmpc_in_periodic_universe.nc')})
settings['frames'] = ('frames', {"dependencies":{'trajectory':'trajectory'}})
settings['axis'] = ('multiple_choices', {'label':'area vectors',
'choices':['a','b','c'],
'nChoices':2,
'default':['a','b']})
settings['name'] = ('string', {'label':'molecule name'})
settings['axis'] = ('multiple_choices', {'label':'area vectors','choices':['a','b','c'],'nChoices':2,'default':['a','b']})
settings['name'] = ('string', {'label':'molecule name','default':'DMPC'})
settings['output_files'] = ('output_files', {'formats':["netcdf","ascii"]})
settings['running_mode'] = ('running_mode',{})
......
......@@ -27,7 +27,7 @@
'''
Created on Apr 10, 2015
@author: pellegrini
@author: Eric C. Pellegrini
'''
from MDANSE.Framework.Jobs.Converters.DCDConverter import DCDConverter
......
......@@ -31,6 +31,7 @@ Created on Apr 10, 2015
'''
import collections
import os
import itertools
import re
......@@ -145,7 +146,7 @@ class CASTEPConverter(Converter):
ancestor = None
settings = collections.OrderedDict()
settings['castep_file'] = ('input_file', {})
settings['castep_file'] = ('input_file', {'default':os.path.join('..','..','..','Data','Trajectories','CASTEP','PBAnew.md')})
settings['output_file'] = ('output_files', {'formats':["netcdf"]})
def initialize(self):
......
......@@ -31,6 +31,7 @@ Created on Apr 10, 2015
'''
import collections
import os
import struct
import numpy
......@@ -279,8 +280,8 @@ class DCDConverter(Converter):
type = None
settings = collections.OrderedDict()
settings['pdb_file'] = ('input_file',{})
settings['dcd_file'] = ('input_file',{})
settings['pdb_file'] = ('input_file',{'default':os.path.join('..','..','..','Data','Trajectories','CHARMM','2vb1.pdb')})
settings['dcd_file'] = ('input_file',{'default':os.path.join('..','..','..','Data','Trajectories','CHARMM','2vb1.dcd')})
settings['output_file'] = ('output_files', {'formats':["netcdf"]})
settings['fold'] = ('boolean', {'default':False,'label':"Fold coordinates in to box"})
......
......@@ -27,10 +27,11 @@
'''
Created on Apr 10, 2015
@author: pellegrini
@author: Eric C. Pellegrini
'''
import collections
import os
import re
import numpy
......@@ -293,8 +294,10 @@ class DL_POLYConverter(Converter):
ancestor = None
settings = collections.OrderedDict()
settings['field_file'] = ('input_file',{'wildcard':"FIELD files|FIELD*|All files|*"})
settings['history_file'] = ('input_file',{'wildcard':"HISTORY files|HISTORY*|All files|*"})
settings['field_file'] = ('input_file',{'wildcard':"FIELD files|FIELD*|All files|*",
'default':os.path.join('..','..','..','Data','Trajectories','DL_Poly','FIELD_cumen')})
settings['history_file'] = ('input_file',{'wildcard':"HISTORY files|HISTORY*|All files|*",
'default':os.path.join('..','..','..','Data','Trajectories','DL_Poly','HISTORY_cumen')})
settings['atom_aliases'] = ('python_object',{'default':{}})
settings['version'] = ('single_choice', {'choices':_HISTORY_FORMAT.keys(), 'default':'2'})
settings['output_file'] = ('output_files', {'formats':["netcdf"]})
......
......@@ -30,6 +30,7 @@ Created on Apr 10, 2015
@author: Eric C. Pellegrini
'''
import os
import collections
import struct
......@@ -235,8 +236,8 @@ class DiscoverConverter(Converter):
ancestor = None
settings = collections.OrderedDict()
settings['xtd_file'] = ('input_file',{})
settings['his_file'] = ('input_file',{})
settings['xtd_file'] = ('input_file',{'default':os.path.join('..','..','..','Data','Trajectories','Discover','sushi.xtd')})
settings['his_file'] = ('input_file',{'default':os.path.join('..','..','..','Data','Trajectories','Discover','sushi.his')})
settings['output_file'] = ('output_files', {'formats':["netcdf"]})
def