/** {@inheritDoc} */ @Override public void setCharge(Double charge) { logger.debug("Setting charge: ", charge); super.setCharge(charge); }
@Test public void testPartialCharge() throws Exception { IAtomContainer mol = new AtomContainer(); Atom atom = new Atom("C"); mol.addAtom(atom); double charge = -0.267; atom.setCharge(charge); IAtomContainer roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol); Assert.assertEquals(1, roundTrippedMol.getAtomCount()); IAtom roundTrippedAtom = roundTrippedMol.getAtom(0); Assert.assertEquals(charge, roundTrippedAtom.getCharge(), 0.0001); }
@Ignore("Have to figure out how to store partial charges in CML2") public void testAtomPartialCharge() throws Exception { IAtomContainer mol = new AtomContainer(); Atom atom = new Atom("N"); double partialCharge = 0.5; atom.setCharge(partialCharge); mol.addAtom(atom); IAtomContainer roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol); Assert.assertEquals(1, roundTrippedMol.getAtomCount()); IAtom roundTrippedAtom = roundTrippedMol.getAtom(0); Assert.assertEquals(atom.getCharge(), roundTrippedAtom.getCharge(), 0.0001); }
@Test public void testCalculate_RDFWeightFunction2() { RDFCalculator calculator = new RDFCalculator(0.0, 5.0, 0.1, 0.0, new IRDFWeightFunction() { @Override public double calculate(org.openscience.cdk.interfaces.IAtom atom, org.openscience.cdk.interfaces.IAtom atom2) { return atom.getCharge() * atom2.getCharge(); } }); AtomContainer h2mol = new org.openscience.cdk.AtomContainer(); Atom h1 = new Atom("H"); h1.setPoint3d(new Point3d(-0.5, 0.0, 0.0)); h1.setCharge(+1.0); Atom h2 = new Atom("H"); h2.setPoint3d(new Point3d(0.5, 0.0, 0.0)); h2.setCharge(-1.0); h2mol.addAtom(h1); h2mol.addAtom(h2); double[] rdf1 = calculator.calculate(h2mol, h1); double[] rdf2 = calculator.calculate(h2mol, h2); // test whether the double array length is ok Assert.assertEquals(51, rdf1.length); // test whether the RDFs are identical Assert.assertEquals(rdf1.length, rdf2.length); for (int i = 0; i < rdf1.length; i++) { Assert.assertEquals(rdf1[i], rdf2[i], 0.00001); } }