Commits

Anonymous committed 7325432

Initial attempt at potentialEnergySum

  • Participants
  • Parent commits 7416c05

Comments (0)

Files changed (5)

File src/test/java/org/xmlcml/cml/chemistry/ArrayToolVisitorTest.java

 
 import nu.xom.Element;
 
+import org.junit.Ignore;
 import org.junit.Test;
 import org.xmlcml.cml.testutil.JumboTestUtils;
 import org.xmlcml.semantic.NodeUtils;
 				newElement, true, 0.0001);		
 	}
 
+	@Ignore
+	@Test
+	public void testPotentialEnergy() {
+		
+		Element element = NodeUtils.parseResource("org/xmlcml/cml/chemistry/potentialEnergyTestSelector.xml");
+		Element arrayToolElement = (Element) element.query("//*[local-name()='arrayTool']").get(0);
+		ArrayToolVisitable visitable = new ArrayToolVisitable(arrayToolElement);
+		ExecutableVisitor visitor = new ExecutableVisitor();
+		Element newElement = visitor.visitElement(visitable);
+		JumboTestUtils.assertEqualsIncludingFloat("test compare", 
+				NodeUtils.parseResource("org/xmlcml/cml/chemistry/potentialEnergyOut.xml"), 
+				newElement, true, 0.0001);		
+	}
 
 }

File src/test/resources/org/xmlcml/cml/chemistry/potentialEnergyOut.xml

+<foo></foo>

File src/test/resources/org/xmlcml/cml/chemistry/potentialEnergySum.xml

+<math display='block'>
+	<apply>
+		<sum />
+		<bvar>
+			<ci>i</ci>
+		</bvar>
+		<lowlimit>
+			<cn>1</cn>
+		</lowlimit>
+		<uplimit>
+			<ci>n</ci>
+		</uplimit>
+		<apply>
+			<times />
+			<apply>
+				<selector />
+				<ci>a</ci>
+				<ci>i</ci>
+			</apply>
+			<apply>
+				<power />
+				<apply>
+					<selector />
+					<ci>b</ci>
+					<ci>i</ci>
+				</apply>
+				<apply>
+					<minus />
+					<apply>
+						<divide />
+						<ci>s</ci>
+						<cn>2</cn>
+					</apply>
+				</apply>
+			</apply>
+		</apply>
+	</apply>
+</math>

File src/test/resources/org/xmlcml/cml/chemistry/potentialEnergyTest.xml

+<computation xmlns:m="http://www.w3.org/1998/Math/MathML"
+	xmlns="http://www.xml-cml.org/semanticcomputation">
+	<arrayTool method="applyFunction"
+		functionRef="src/test/resources/org/xmlcml/cml/chemistry/potentialEnergySum.xml"
+		xpath="./*[local-name()='array']"  param-s="8.675"
+		functionVar="r">
+
+	<array xmlns="http://www.xml-cml.org/schema" dataType="xsd:double"
+		id="a1" size="60">
+		1 2 3 4 5
+		6 7 8 9 10
+		11 12 13 15 16
+		17 18 19 20 21
+		22 23 24 25 26
+		27 28 29 31 32
+		33 34 35 36 37
+		38 39 40 41 42
+		43 44 45 47 48
+		49 50 51 52 53
+		54 55 57 58 59 
+		60 61 63 64 65
+	</array>
+	<array xmlns="http://www.xml-cml.org/schema" dataType="xsd:double"
+		id="a2" size="60">
+		12 6 24 12 24
+		8 48 6 36 24
+		24 24 72 48 12
+		48 30 72 24 48
+		24 48 8 84 24
+		96 48 24 96 6
+		96 48 48 36 120
+		24 48 24 48 48
+		120 24 120 96 24 
+		108 30 48 72 72
+		32 144 96 72 72
+		48 120 144 12 72
+	</array>
+	
+	
+	<array xmlns="http://www.xml-cml.org/schema" dataType="xsd:double"
+		id="sVal" size="9">
+         6 7 8 9 10 12 14 16 18
+	</array>
+	
+	
+	</arrayTool>
+
+</computation>

File src/test/resources/org/xmlcml/cml/chemistry/potentialEnergyTestSelector.xml

+<computation xmlns:m="http://www.w3.org/1998/Math/MathML"
+	xmlns="http://www.xml-cml.org/semanticcomputation">
+	<arrayTool method="applyFunction"
+		functionRef="src/test/resources/org/xmlcml/cml/chemistry/potentialEnergySum.xml"
+		xpath-1="./*[local-name()='array' and @id='a1']" var-1="a" 
+		xpath-2="./*[local-name()='array' and @id='a2']" var-2="b"
+		param-s="8.675" 
+		param-n="10">
+
+	<array xmlns="http://www.xml-cml.org/schema" dataType="xsd:double"
+		id="a1" size="60">
+		1 2 3 4 5
+		6 7 8 9 10
+		11 12 13 15 16
+		17 18 19 20 21
+		22 23 24 25 26
+		27 28 29 31 32
+		33 34 35 36 37
+		38 39 40 41 42
+		43 44 45 47 48
+		49 50 51 52 53
+		54 55 57 58 59 
+		60 61 63 64 65
+	</array>
+	<array xmlns="http://www.xml-cml.org/schema" dataType="xsd:double"
+		id="a2" size="60">
+		12 6 24 12 24
+		8 48 6 36 24
+		24 24 72 48 12
+		48 30 72 24 48
+		24 48 8 84 24
+		96 48 24 96 6
+		96 48 48 36 120
+		24 48 24 48 48
+		120 24 120 96 24 
+		108 30 48 72 72
+		32 144 96 72 72
+		48 120 144 12 72
+	</array>
+	
+	
+	<array xmlns="http://www.xml-cml.org/schema" dataType="xsd:double"
+		id="sVal" size="9">
+         6 7 8 9 10 12 14 16 18
+	</array>
+	
+	
+	</arrayTool>
+
+</computation>