use of org.apache.commons.configuration.CompositeConfiguration in project ffx by mjschnie.
the class CrystalReciprocalSpaceTest method test1N7SPermanent.
/**
* Test of permanent method, of class CrystalReciprocalSpace.
*/
@Test
public void test1N7SPermanent() {
String filename = "ffx/xray/structures/1N7S.pdb";
int index = filename.lastIndexOf(".");
String name = filename.substring(0, index);
// load the structure
ClassLoader cl = this.getClass().getClassLoader();
File structure = new File(cl.getResource(filename).getPath());
PotentialsUtils potutil = new PotentialsUtils();
MolecularAssembly mola = potutil.open(structure);
CompositeConfiguration properties = mola.getProperties();
Crystal crystal = new Crystal(39.767, 51.750, 132.938, 90.00, 90.00, 90.00, "P212121");
Resolution resolution = new Resolution(1.45);
ReflectionList reflectionList = new ReflectionList(crystal, resolution);
DiffractionRefinementData refinementData = new DiffractionRefinementData(properties, reflectionList);
mola.finalize(true, mola.getForceField());
ForceFieldEnergy energy = mola.getPotentialEnergy();
List<Atom> atomList = mola.getAtomList();
Atom[] atomArray = atomList.toArray(new Atom[atomList.size()]);
// set up FFT and run it
ParallelTeam parallelTeam = new ParallelTeam();
CrystalReciprocalSpace crs = new CrystalReciprocalSpace(reflectionList, atomArray, parallelTeam, parallelTeam);
crs.computeAtomicDensity(refinementData.fc);
// tests
ComplexNumber b = new ComplexNumber(-828.584, -922.704);
HKL hkl = reflectionList.getHKL(1, 1, 4);
ComplexNumber a = refinementData.getFc(hkl.index());
System.out.println("1 1 4: " + a.toString() + " | " + b.toString() + " | " + a.divides(b).toString());
assertEquals("1 1 4 reflection should be correct", -753.4722104328416, a.re(), 0.0001);
assertEquals("1 1 4 reflection should be correct", -1012.1341308707799, a.im(), 0.0001);
b.re(-70.4582);
b.im(-486.142);
hkl = reflectionList.getHKL(2, 1, 10);
a = refinementData.getFc(hkl.index());
System.out.println("2 1 10: " + a.toString() + " | " + b.toString() + " | " + a.divides(b).toString());
assertEquals("2 1 10 reflection should be correct", -69.39660884054359, a.re(), 0.0001);
assertEquals("2 1 10 reflection should be correct", -412.0147625765328, a.im(), 0.0001);
}
use of org.apache.commons.configuration.CompositeConfiguration in project ffx by mjschnie.
the class CIFFilterTest method testCIFFilter3DYC.
@Test
public void testCIFFilter3DYC() {
String filename = "ffx/xray/structures/3DYC.ent";
ClassLoader cl = this.getClass().getClassLoader();
File cifFile = new File(cl.getResource(filename).getPath());
// load any properties associated with it
CompositeConfiguration properties = Keyword.loadProperties(cifFile);
CIFFilter cifFilter = new CIFFilter();
ReflectionList reflectionList = cifFilter.getReflectionList(cifFile);
assertNotNull(" Reflection list should not be null", reflectionList);
DiffractionRefinementData refinementData = new DiffractionRefinementData(properties, reflectionList);
assertTrue(" CIF data not read in correctly", cifFilter.readFile(cifFile, reflectionList, refinementData, properties));
HKL hkl = reflectionList.getHKL(58, 0, 13);
assertEquals("58 0 13 F", 99.7, refinementData.getF(hkl.index()), 0.01);
assertEquals("58 0 13 sigF", 69.7, refinementData.getSigF(hkl.index()), 0.01);
assertEquals("58 0 13 freeR value", 1, refinementData.freer[hkl.index()]);
hkl = reflectionList.getHKL(28, 20, 5);
assertEquals("28 20 5 F", 428.1, refinementData.getF(hkl.index()), 0.01);
assertEquals("28 20 5 sigF", 10.1, refinementData.getSigF(hkl.index()), 0.01);
assertEquals("28 20 5 freeR value", 0, refinementData.freer[hkl.index()]);
}
use of org.apache.commons.configuration.CompositeConfiguration in project ffx by mjschnie.
the class MolecularDynamics method assemblyInfo.
protected void assemblyInfo() {
assemblies.stream().parallel().forEach((ainfo) -> {
MolecularAssembly mola = ainfo.getAssembly();
CompositeConfiguration aprops = ainfo.props;
File file = mola.getFile();
String filename = FilenameUtils.removeExtension(file.getAbsolutePath());
File archFile = ainfo.archiveFile;
if (archFile == null) {
archFile = new File(filename + ".arc");
ainfo.archiveFile = XYZFilter.version(archFile);
}
if (ainfo.pdbFile == null) {
String extName = FilenameUtils.getExtension(file.getName());
if (extName.toLowerCase().startsWith("pdb")) {
ainfo.pdbFile = file;
} else {
ainfo.pdbFile = new File(filename + ".pdb");
}
}
if (ainfo.xyzFilter == null) {
ainfo.xyzFilter = new XYZFilter(file, mola, mola.getForceField(), aprops);
}
if (ainfo.pdbFilter == null) {
ainfo.pdbFilter = new PDBFilter(ainfo.pdbFile, mola, mola.getForceField(), aprops);
}
});
}
use of org.apache.commons.configuration.CompositeConfiguration in project ffx by mjschnie.
the class AlgorithmUtils method md.
/**
* Performs molecular dynamics on a MolecularAssembly.
*
* @param assembly the MolecularAssembly to do MD on.
* @param nStep the number of MD steps.
* @param timeStep the MD time step.
* @param printInterval the time between logging statements.
* @param saveInterval the time between saving restart files.
* @param temperature the target temperature.
* @param initVelocities if true, reset velocities from a Maxwell
* distribution.
* @param dyn a dynamics restart.
*/
@Override
public void md(MolecularAssembly assembly, int nStep, double timeStep, double printInterval, double saveInterval, double temperature, boolean initVelocities, File dyn) {
if (assembly == null) {
logger.info(" No active system to minimize.");
} else {
CompositeConfiguration properties = Keyword.loadProperties(assembly.getFile());
MolecularDynamics molecularDynamics = new MolecularDynamics(assembly, assembly.getPotentialEnergy(), properties, null, ThermostatEnum.BUSSI, IntegratorEnum.BEEMAN);
molecularDynamics.dynamic(nStep, timeStep, printInterval, saveInterval, temperature, initVelocities, dyn);
}
}
use of org.apache.commons.configuration.CompositeConfiguration in project ffx by mjschnie.
the class ForceFieldEnergyOpenMM method loadPlatform.
/**
* Load an OpenMM Platform
*/
private void loadPlatform(Platform requestedPlatform) {
// Print out the OpenMM Version.
Pointer version = OpenMM_Platform_getOpenMMVersion();
logger.log(Level.INFO, " OpenMM Version: {0}", version.getString(0));
// Print out the OpenMM plugin directory.
Pointer pluginDir = OpenMM_Platform_getDefaultPluginsDirectory();
String pluginDirString = pluginDir.getString(0);
if (SystemUtils.IS_OS_WINDOWS) {
pluginDirString = pluginDirString + "/plugins";
}
logger.log(Level.INFO, " OpenMM Plugin Dir: {0}", pluginDirString);
/**
* Load plugins and print out plugins.
*
* Call the method twice to avoid a bug where not all platforms are list
* after the first call.
*/
PointerByReference plugins = OpenMM_Platform_loadPluginsFromDirectory(pluginDirString);
OpenMM_StringArray_destroy(plugins);
plugins = OpenMM_Platform_loadPluginsFromDirectory(pluginDirString);
int numPlugins = OpenMM_StringArray_getSize(plugins);
logger.log(Level.INFO, " Number of OpenMM Plugins: {0}", numPlugins);
boolean cuda = false;
for (int i = 0; i < numPlugins; i++) {
String pluginString = stringFromArray(plugins, i);
logger.log(Level.INFO, " Plugin: {0}", pluginString);
if (pluginString.toUpperCase().contains("AMOEBACUDA")) {
cuda = true;
}
}
OpenMM_StringArray_destroy(plugins);
/**
* Extra logging to print out plugins that failed to load.
*/
if (logger.isLoggable(Level.FINE)) {
PointerByReference pluginFailers = OpenMM_Platform_getPluginLoadFailures();
int numFailures = OpenMM_StringArray_getSize(pluginFailers);
for (int i = 0; i < numFailures; i++) {
String pluginString = stringFromArray(pluginFailers, i);
logger.log(Level.FINE, " Plugin load failure: {0}", pluginString);
}
OpenMM_StringArray_destroy(pluginFailers);
}
int numPlatforms = OpenMM_Platform_getNumPlatforms();
logger.log(Level.INFO, " Number of OpenMM Platforms: {0}", numPlatforms);
/**
* for (int i = 0; i < numPlatforms; i++) { PointerByReference
* currentPlatform = OpenMM_Platform_getPlatform(i); Pointer
* platformName = OpenMM_Platform_getName(currentPlatform);
* logger.log(Level.INFO, " Platform: {0}", platformName.getString(0));
* OpenMM_Platform_destroy(currentPlatform); }
*/
String defaultPrecision = "mixed";
String precision = molecularAssembly.getForceField().getString(ForceField.ForceFieldString.PRECISION, defaultPrecision).toLowerCase();
precision = precision.replace("-precision", "");
switch(precision) {
case "double":
case "mixed":
case "single":
logger.info(String.format(" Using precision level %s", precision));
break;
default:
logger.info(String.format(" Could not interpret precision level %s, defaulting to %s", precision, defaultPrecision));
precision = defaultPrecision;
break;
}
Comm world = Comm.world();
int size = world.size();
int defDeviceIndex = 0;
if (size > 1) {
int rank = world.rank();
CompositeConfiguration props = molecularAssembly.getProperties();
// 0/no-arg would indicate "just put everything on device specified by CUDA_DEVICE".
// TODO: Get the number of CUDA devices from the CUDA API as the alternate default.
int numCudaDevices = props.getInt("numCudaDevices", 0);
if (numCudaDevices > 0) {
defDeviceIndex = rank % numCudaDevices;
logger.info(String.format(" Placing energy from rank %d on device %d", rank, defDeviceIndex));
}
}
int deviceID = molecularAssembly.getForceField().getInteger(ForceField.ForceFieldInteger.CUDA_DEVICE, defDeviceIndex);
String deviceIDString = Integer.toString(deviceID);
if (cuda && requestedPlatform != Platform.OMM_REF) {
platform = OpenMM_Platform_getPlatformByName("CUDA");
OpenMM_Platform_setPropertyDefaultValue(platform, pointerForString("CudaDeviceIndex"), pointerForString(deviceIDString));
OpenMM_Platform_setPropertyDefaultValue(platform, pointerForString("Precision"), pointerForString(precision));
logger.info(String.format(" Selected OpenMM AMOEBA CUDA Platform (Device ID: %d)", deviceID));
} else {
platform = OpenMM_Platform_getPlatformByName("Reference");
logger.info(" Selected OpenMM AMOEBA Reference Platform");
}
}
Aggregations