Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "deps/libcanon"]
path = deps/libcanon
url = https://github.com/tschijnmo/libcanon.git
[submodule "deps/DummyRDD"]
path = deps/DummyRDD
url = https://github.com/DrudgeCAS/DummyRDD
18 changes: 14 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.. image:: https://circleci.com/gh/tschijnmo/drudge.svg?style=shield
:target: https://circleci.com/gh/tschijnmo/drudge
.. image:: https://circleci.com/gh/DrudgeCAS/drudge.svg?style=shield
:target: https://circleci.com/gh/DrudgeCAS/drudge

.. image:: https://travis-ci.org/tschijnmo/drudge.svg?branch=master
:target: https://travis-ci.org/tschijnmo/drudge
.. image:: https://travis-ci.org/DrudgeCAS/drudge.svg?branch=master
:target: https://travis-ci.org/DrudgeCAS/drudge

.. image:: https://coveralls.io/repos/github/tschijnmo/drudge/badge.svg?branch=master
:target: https://coveralls.io/github/tschijnmo/drudge?branch=master
Expand Down Expand Up @@ -58,6 +58,14 @@ with heavy dependence on tensor contraction and sums of tensor contractions,
substantial optimization could be given.


Documentation/Installation
------
Documentation Pages are located at the github pages `documentation`_ site.
Installation instructions can be seen at `installation`_.




Drudge is developed by Jinmo Zhao and Prof Gustavo E Scuseria at Rice
University, and was supported as part of the Center for the Computational Design
of Functional Layered Materials, an Energy Frontier Research Center funded by
Expand All @@ -71,3 +79,5 @@ Award DE-SC0012575.
.. _Clifford algebras: https://en.wikipedia.org/wiki/Clifford_algebra
.. _su(2) algebra: https://en.m.wikipedia.org/wiki/Special_unitary_group#Lie_Algebra
.. _gristmill: https://github.com/tschijnmo/gristmill
.. _documentation: https://drudgecas.github.io/drudge/
.. _installation: https://drudgecas.github.io/drudge/install.html
1 change: 1 addition & 0 deletions deps/DummyRDD
Submodule DummyRDD added at 008934
8 changes: 4 additions & 4 deletions drudge/drs.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,13 @@ def __missing__(self, key: str):
if key.startswith('__') and key.endswith('__'):
raise KeyError(key)

for entry, excl in self._path:
if hasattr(entry, key) and key not in excl:
resolv = getattr(entry, key)
for entry, excl in self._path: #For every module/variable in the environment
if hasattr(entry, key) and key not in excl: # check if our key is defined in it
resolv = getattr(entry, key) # if found, pull it from the environment
break
else:
continue
else:
else: # if we didn't find earlier and break, default to defining it instead
resolv = DrsSymbol(self._drudge, key)
return resolv

Expand Down
2 changes: 1 addition & 1 deletion drudge/drudge.py
Original file line number Diff line number Diff line change
Expand Up @@ -3490,7 +3490,7 @@ def _union(orig, new):


def _inters(orig, new):
"""Make the interaction of two sets.
"""Make the intersection of two sets.

If the original is a None value, a new set will be created with elements
from the new set. When both operands are None, the result is None.
Expand Down
13 changes: 11 additions & 2 deletions drudge/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def __call__(self, *args, **kwargs):
return self._func(*args, **kwargs)


class _EnumSymbsMeta(ManagedProperties):
class _EnumSymbsMeta(type):
"""The meta class for enumeration symbols.

The primary purpose of this metaclass is to set the concrete singleton
Expand Down Expand Up @@ -140,7 +140,7 @@ class EnumSymbs(AtomicExpr, metaclass=_EnumSymbsMeta):

Subclasses can set `_symbs_` inside the class body to be a sequence of
string pairs. Then attributes named after the first field of the pairs will
be created, with the LaTeX form controlled by the second pair.
be created, with the LaTeX form controlled by the second field of the pair.

The resulted values are valid SymPy expressions. They are ordered according
to their order in the given enumeration sequence.
Expand Down Expand Up @@ -222,6 +222,15 @@ def __rsub__(self, other):
"""
return self.__sub__(other)

def __getstate__(self):
"""Retrieve state of object for pickling/serialization"""
return {slot: getattr(self, slot) for slot in self.__slots__}

def __setstate__(self, state):
"""Create state of object for deserialization"""
for key, value in state.items():
setattr(self, key, value)

def sort_key(self, order=None):
return (
self.class_key(),
Expand Down
79 changes: 79 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash
#
# INSTRUCTIONS:
# 0) Check the ENV_NAME doesn't collide with previously defined environments
# - List current environments with `conda env list`
# 1) Run this With `source install_in.sh`
#

ENV_NAME=drudge

# Ensure latest conda installed
conda update -n base -c defaults conda -y

# Conda env creation
echo "Creating Conda Environment"
conda create --name $ENV_NAME python=3.9 -y
conda activate $ENV_NAME

# Choose the correct conda package list
if [[ "$(uname -m)" == "x86_64" ]]; then
# conda install --name $ENV_NAME --file install/env_x86.txt -y
conda install conda-forge::gcc==14.2.0 -y
conda install conda-forge::gxx_linux-64==14.2.0 -y
else
# echo "CONDA ENVIRONMENT FOR arm64 NOT YET VERIFIED"
# conda install --name $ENV_NAME --file install/env_arm.txt -y
echo ""
fi

conda install IPython==8.15.0 -y
conda install sympy==1.13.2 -y
conda install pyspark==3.4.1 -y
conda install jinja2 -y
conda install pytest -y
conda install coveralls -y

# Force Conda into Base, then into created environment
echo "Initializing Conda"
conda init
conda activate $ENV_NAME


# Clone repository
echo "Cloning Submodules"
git submodule update --init --recursive


# Setup Vars
echo "Setting env vars"
export PYTHONPATH=$(pwd)
export DUMMY_SPARK=1

# Build cpp files
echo "Building cpp files"
python3 setup.py build
python3 setup.py install

# Copy the cpp files where needed
# echo "Moving cpp files"
# cp build/lib.linux-x86_64-cpython-39/drudge/wickcore.cpython-39-x86_64-linux-gnu.so drudge/
# cp build/lib.linux-x86_64-cpython-39/drudge/canonpy.cpython-39-x86_64-linux-gnu.so drudge/

# Add Dummy Spark
echo "Getting Dummy Spark"
git clone https://github.com/DrudgeCAS/DummyRDD ../dummyRDD/

echo "Moving Dummy Spark"
cp -r ../dummyRDD/dummy_spark .

# Remove unneeded folder
rm -rf ../dummyRDD/
Comment on lines +67 to +71
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we want to avoid installation of dummyRDD?
I agree that this can simplify things by reducing number of repos/packages to be installed, but it introduces another manual copy-paste. Either way is fine with me.


echo "Installation Complete!"
echo "Assuming you ran this with '\''source'\'' you'\''re now inside the drudge folder. To get started using drudge you'll want to do 3 things after opening your chosen IDE to your code location:"
echo " 1) Ensure your Python Interpreter is set to the Conda Environment Python we just created"
echo " 2) Ensure this conda environment is activated with '\''conda activate drudge '\'' in the terminal which runs your program"
echo " 3) Set your pythonpath to the build directory of this repository like '\''export PYTHONPATH=\$PYTHONPATH:/path/to/drudge/build'\''"
echo " "
echo "Have Fun!"
6 changes: 6 additions & 0 deletions install/env_arm.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
IPython==8.15.0
sympy==1.13.2
pyspark==3.4.1
jinja2
pytest
coveralls
8 changes: 8 additions & 0 deletions install/env_x86.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
conda-forge::gcc==14.2.0
conda-forge::gxx_linux-64==14.2.0
IPython==8.15.0
sympy==1.13.2
pyspark==3.4.1
jinja2
pytest
coveralls
2 changes: 1 addition & 1 deletion tests/free_algebra_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from conftest import skip_in_spark


@pytest.fixture(scope='module')
@pytest.fixture
def free_alg(spark_ctx):
"""Initialize the environment for a free algebra."""

Expand Down
5 changes: 3 additions & 2 deletions tests/nuclear_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def test_varsh_872_5(nuclear: NuclearBogoliubovDrudge):

TODO: Investigate its failure in Apache Spark environment.
"""

dr = nuclear
a, alpha, b, beta, b_prm, beta_prm = symbols(
'a alpha b beta bprm betaprm', integer=True
Expand All @@ -132,7 +133,7 @@ def test_varsh_872_5(nuclear: NuclearBogoliubovDrudge):
)
for sums_i in [sums, reversed(sums)]:
tensor = dr.sum(*sums_i, amp)
res = tensor.deep_simplify().merge()
res = tensor.simplify_am().merge() #previously used deep_simplify
assert res.n_terms == 1
term = res.local_terms[0]
assert len(term.sums) == 0
Expand Down Expand Up @@ -208,7 +209,7 @@ def test_wigner3j_sum_to_wigner6j(nuclear: NuclearBogoliubovDrudge):
((-1) ** (j3 - m3) / (2 * j3 + 1))
* KroneckerDelta(j3, jprm3) * KroneckerDelta(m3, mprm3)
* Wigner6j(j1, j2, j3, j4, j5, j6)
).expand().simplify()
).expand().simplify(doit=False)

# For performance reason, just test a random arrangement of the summations.
random.shuffle(sums)
Expand Down
Loading