]> git.unchartedbackwaters.co.uk Git - francis/ofc.git/commitdiff
Add experiments with new DSL syntax.
authorFrancis Russell <francis@unchartedbackwaters.co.uk>
Wed, 5 Sep 2012 15:28:41 +0000 (16:28 +0100)
committerFrancis Russell <francis@unchartedbackwaters.co.uk>
Wed, 5 Sep 2012 15:28:41 +0000 (16:28 +0100)
examples/density_on_dbl_grid.ofl [new file with mode: 0644]
examples/integrals_grad.ofl
examples/integrals_locpot.ofl [new file with mode: 0644]
examples/integrals_pos.ofl [new file with mode: 0644]

diff --git a/examples/density_on_dbl_grid.ofl b/examples/density_on_dbl_grid.ofl
new file mode 100644 (file)
index 0000000..7904cea
--- /dev/null
@@ -0,0 +1,21 @@
+# Parameter information
+Function[SpinIndex] density_dbl
+Scalar[SpinIndex, FunctionIndex, FunctionIndex] denskern
+Scalar[FunctionIndex, FunctionIndex] overlap
+Function[FunctionIndex] ngwfs
+SpinIndex spin
+FunctionIndex alpha, beta
+
+# Computation
+density_dbl[spin] = sum(bra[alpha]*sum(denskern[spin, alpha, beta] * ngwfs[beta], beta]), alpha)
+
+# Implementation specific
+target ONETEP
+Variable density_dbl    is fortran_param with name("density_dbl"), type("double(:,:,:,:)"), shape(cell_double_grid*spin)
+Variable denskern       is fortran_param with name("denskern"), type("spam3(:)"), shape(direction*matrix)
+Variable overlap        is fortran_param with name("overlap"), type("spam3")
+Parameter ngwf_basis    is fortran_param with name("ngwf_basis"), type("func_basis")
+Parameter ngwfs_on_grid is fortran_param with name("ngwfs_on_grid"), type("double(:)")
+Variable ngwfs          is ppd_function_set with data(ngwfs_on_grid), basis(ngwf_basis)
+OutputFunction _        is fortran_function with name("density_on_dbl_grid"), 
+                                                 params(density_dbl, denskern, overlap, ngwfs_on_grid, ngwf_basis)
index 5d693d8af292ff93cb02a355e624d60eb6c7da07..3112da120f9746b58b77c435b2fef71d72f57164 100644 (file)
@@ -9,12 +9,11 @@ kinet[i, alpha, beta] = inner(bra[alpha], derivative(ket[beta], i))
 
 # Implementation specific
 target ONETEP
-Variable kinet        = FortranVariable("kinet", spam3(:))
-Variable bra_basis    = FortranVariable("bra_basis", func_basis)
-Variable bras_on_grid = FortranVariable("bras_on_grid", double(:))
-Variable ket_basis    = FortranVariable("ket_basis", func_basis)
-Variable kets_on_grid = FortranVariable("kets_on_grid", double(:))
-Variable bra          = PPDFunctionSet(bras_on_grid, bra_basis)
-Variable ket          = PPDFunctionSet(kets_on_grid, ket_basis)
-
-FortranFunction("integrals_grad", kinet, bras_on_grid, bra_basis, kets_on_grid, ket_basis)
+Variable kinet        = FortranVariable("kinet", "spam3(:)")
+Variable bra_basis    = FortranVariable("bra_basis", "func_basis")
+Variable bras_on_grid = FortranVariable("bras_on_grid", "double(:)")
+Variable ket_basis    = FortranVariable("ket_basis", "func_basis")
+Variable kets_on_grid = FortranVariable("kets_on_grid", "double(:)")
+Variable bra          = PPDFunctionSet(bras_on_grid, "bra_basis")
+Variable ket          = PPDFunctionSet(kets_on_grid, "ket_basis")
+Variable output       = FortranFunction("integrals_grad", kinet, bras_on_grid, bra_basis, kets_on_grid, ket_basis)
diff --git a/examples/integrals_locpot.ofl b/examples/integrals_locpot.ofl
new file mode 100644 (file)
index 0000000..e128eae
--- /dev/null
@@ -0,0 +1,21 @@
+# Parameter information
+Array[FunctionIndex, FunctionIndex] locpot
+Function potential_fine
+FunctionSet bra, ket
+FunctionIndex alpha, beta
+
+# Computation
+locpot[alpha, beta] = inner(bra[alpha], potential_fine*ket[beta])
+
+# Implementation specific
+target ONETEP
+Variable locpot         = FortranVariable("locpot", "spam3")
+Variable bra_basis      = FortranVariable("bra_basis", "func_basis")
+Variable bras_on_grid   = FortranVariable("bras_on_grid", "double(:)")
+Variable ket_basis      = FortranVariable("ket_basis", "func_basis")
+Variable kets_on_grid   = FortranVariable("kets_on_grid", "double(:)")
+Variable potential_fine = PsincCoarseFunction(FortranVariable("potential_fine", "double(:,:,:)"))
+Variable bra            = PPDFunctionSet(bras_on_grid, bra_basis)
+Variable ket            = PPDFunctionSet(kets_on_grid, ket_basis)
+Variable output         = FortranFunction("integrals_locpot", locpot, bras_on_grid, bra_basis, 
+                                          kets_on_grid, ket_basis, potential_fine)
diff --git a/examples/integrals_pos.ofl b/examples/integrals_pos.ofl
new file mode 100644 (file)
index 0000000..5b7bb57
--- /dev/null
@@ -0,0 +1,21 @@
+# Parameter information
+Array[SpatialIndex, FunctionIndex, FunctionIndex] rmat
+FunctionSet bra, ket
+FunctionIndex alpha, beta
+Scalar order
+SpatialIndex i
+
+# Computation
+rmat[i, alpha, beta] = inner(bra[alpha], ket[beta] * pos[i]^order)
+
+# Implementation specific
+target ONETEP
+Variable rmat        = FortranVariable("rmat", "spam3(:)")
+Variable bra_basis    = FortranVariable("bra_basis", "func_basis")
+Variable bras_on_grid = FortranVariable("bras_on_grid", "double(:)")
+Variable order        = FortranVariable("order", "integer")
+Variable ket_basis    = FortranVariable("ket_basis", "func_basis")
+Variable kets_on_grid = FortranVariable("kets_on_grid", "double(:)")
+Variable bra          = PPDFunctionSet(bras_on_grid, "bra_basis")
+Variable ket          = PPDFunctionSet(kets_on_grid, "ket_basis")
+Variable output       = FortranFunction("integrals_pos", rmat, bras_on_grid, bra_basis, kets_on_grid, ket_basis, order)