Skip to content

Commit

Permalink
Merge pull request #69 from Erastova-group/analysis_fixes
Browse files Browse the repository at this point in the history
merging analysis fixes
  • Loading branch information
sarahvs99 authored Feb 28, 2024
2 parents 6a61bee + c4f5a1d commit f177280
Show file tree
Hide file tree
Showing 32 changed files with 256 additions and 13 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
Empty file added package/ClayCode/plot/consts.py
Empty file.
Empty file.
Empty file.
37 changes: 37 additions & 0 deletions package/ClayCode/plots/dataclasses.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from __future__ import annotations


class Cutoff(str):
def __new__(cls, length):
string = f"{int(length):02}"
return super().__new__(cls, string)

def __init__(self, length):
self.num = float(length)

def __float__(self):
return float(self.num)

def __int__(self):
return int(self.num)

def __str__(self):
return self


class Bins(str):
def __new__(cls, length):
string = f"{float(length):.02f}"[2:]
return super().__new__(cls, string)

def __init__(self, length):
self.num = float(length)

def __float__(self):
return float(self.num)

def __int__(self):
return int(self.num)

def __str__(self):
return self
23 changes: 10 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,18 @@ dependencies = ['matplotlib>=3.6.2',
'numba>=0.57',
'pytest',
"nglview>=3.0",
]
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent"
"unicodeit"
]
classifiers = ["Programming Language :: Python :: 3",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent"]

[project.scripts]
ClayCode = "ClayCode:__main__.run"

[tool.setuptools.packages.find]
namespaces = true
where=['package', 'tests']
where = ['package', 'tests']

[tool.setuptools]
include-package-data = true
Expand Down Expand Up @@ -75,16 +74,14 @@ exclude = '''
)/
'''
[project.optional-dependencies]
test = [
"pytest>=6.0",
"pytest-xdist>=2.5",
"pytest-cov>=3.0",

test = ["pytest>=6.0",
"pytest-xdist>=2.5",
"pytest-cov>=3.0",
]

[tool.pytest.ini_options]
addopts = "-s"
minversion = "6.0"
testpaths = [
"ClayCodeTests",
testpaths = ["ClayCodeTests",
]
python_files = ["test_*.py", "*_test.py", "test.py"]
Empty file added tests/ClayCodeTests/__init__.py
Empty file.
Empty file.
Empty file.
19 changes: 19 additions & 0 deletions tests/ClayCodeTests/builder/data/exp_clay.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
sheet,element,KGa-1,NAu-1-fe,NAu-2-fe,NG-1,SWa-1,SWy-1,IMt-1,LDH31,IMt-2,SWy-1-simplified,SWy-123,SWy-1-simplified-feo,IMt-1,SAz-1
T,Si,3.83,6.98,7.55,7.08,7.09,7.98,6.77,,6.77,8,7.98,8,6.77,8
T,Al,0.17,0.95,0.16,0.92,0.91,0.02,1.23,,1.23,,0.02,,1.23,
T,Fe,,0.07,0.29,,,,,,,,,,,
O,Fe,,3.61,3.54,3.75,3.08,0.41,,,0.82,,,,,
O,Fe3,0.02,,,,,,0.76,,,,0.41,3,0.76,0.12
O,Fe2,,,,,,,0.06,,,,,,0.06,
O,Al,3.86,0.36,0.34,0.17,0.61,3.01,2.69,1,2.69,3,3.01,0,2.69,2.71
O,Mg,,0.04,0.05,0.08,0.24,0.54,0.43,3,0.43,1,0.54,1,0.43,1.11
O,Mn,,,,,,0.01,,,,,0.01,,,0.01
O,Ti,0.11,,,,0.07,,,,,,,,,0.03
I,Ca,0.01,0.525,0.36,0.32,0.36,0.12,0.06,,0.06,1,1,1,0.06,0.39
I,Na,0.01,,,0.01,,0.32,,,,,,1,,0.36
I,Mg,0.02,,,0.15,0.18,,0.09,,0.09,,,,0.09,
I,K,0.01,,,0.03,0.01,0.05,1.37,,1.37,,,,1.37,0.02
I,Cl,,,,,,,,1,,,,,,
C,T,-0.17,-1.02,-0.45,-0.92,-0.91,-0.02,-1.23,,-1.23,0,-0.02,0,-1.23,0
C,O,0.11,-0.03,-0.27,-0.08,-0.18,-0.53,-0.44,1,-0.44,-1,-0.53,-1,-0.44,-1.08
C,tot,-0.06,-1.05,-0.72,-0.99,-1.09,-0.55,-1.68,1,-1.68,-1,-0.55,-1,-1.68,-1.08
152 changes: 152 additions & 0 deletions tests/ClayCodeTests/builder/data/input_empty.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@

# =============================================================================
# General specifications for clay model construction
# =============================================================================

# =============================================================================
# Required Parameters
# =============================================================================

OUTPATH: '/storage/clay_models'

# name of system
SYSNAME: IMt-1

# specify whether new clay model should be constructed:
# new - a new clay model is constructed
# load - sheet coordinates or unit cell sequences are loaded from existent ._gro or .npy files
# load: [X, Y]
# with X - 'np' or '_gro', Y - '.npy' or '._gro' filename
# False - no clay model is constructed

BUILD: new

# name of .csv file with target stoichiometry
CLAY_COMP: package/ClayCode/builder/tests/data/exp_non.csv

# clay type available options in 'clay_units' directory:
# Dioctahedral 2:1 - D21
# Trioctahedral 2:1 - T21
# Dioctahedral 1:1 - D11
# Trioctahedral 1:1 - T11
# layered double hydroxide 3:1 - L31
# layered double hydroxide 2:1 - L21
# Sepiolite - SEP

CLAY_TYPE: D21


# =============================================================================
# Optional: Clay Sheet and Interlayer Specifications
# =============================================================================

# number of unit cells in x direction (Default 7)
X_CELLS: 6 #7

# number of unit cells in y direction (Default 5)
Y_CELLS: 4 # 5

# number of unit cells in z direction (Default 3)
N_SHEETS: 2 # 3

# ----------------------------------------------------------------------------
# Optional: Unit Cell Composition and Ratios input
# if not given, these will be calculated from data in the CLAY_COMP .csv file
# (Default UC_INDEX_LIST: [], UC_RATIOS_LIST: [])
# -----------------------------------------------------------------------------

# required UCs to builder system as list
# UC_INDEX_LIST: [1]

# probability list of unit cells in system
# p(tot) = 1.00
# UC_RATIOS_LIST: [1]

# -----------------------------------------------------------------------------

# interlayer solvent present or not (Default True)
IL_SOLV: False

# -----------------------------------------------------------------------------
# Optional: Interlayer Ion Specification Options (comment the other options!)
# (Default UC_WATERS: 20)
# -----------------------------------------------------------------------------

# 1. Number of water molecules that should be added per ion (ION_WATERS)
# a. as ion species dictionary for hydration number
# ION_WATERS = {'Ca': 12,
# 'Na': 12
# }

# b. as ion species int for hydration number
# ION_WATERS = 12

# 3. OR per unit cell
UC_WATERS: 20

# 4. OR for a target d-spacing value in A
# SPACING_WATERS = 10.0

# =============================================================================
# Optional: Simulation Box Specifications
# =============================================================================

# full simulation box height in A (Default 150.0)
BOX_HEIGHT: 50 # 150.0

# =============================================================================
# Optional: Solvation and Bulk Ions Specifications
# =============================================================================

# Bulk solvent added or not (Default: True)
BULK_SOLV: True

# Ion species and concentration in mol/L name to add in bulk solvent
# (Default: BULK_IONS:
# Na: 0.1)

BULK_IONS:
Na: 0
Cl: 0
# Na: 0.1
# Cl: 0.05

# =============================================================================
# Optional: Simulation Runs Specifications
# =============================================================================

# Generate scripts and '.mdp' files for simulation runs.
# Available options:
# EM - energy minimisation
# EQ - equilibration
# D-SPACE - d-spacing equilibration
# P - production
# SIMINP: [EM, D-SPACE]

# select where EM and EQ should be run (Default: False)
# MDRUNS_REMOTE: False

# -----------------------------------------------------------------------------
# d-spacing equilibration options
# -----------------------------------------------------------------------------

# Target d-spacing in A
# D_SPACE: 19.5

# Water molecules to be removed at a time during d-spacing equilibration runs
# REMOVE_STEPS = 1000

# Absolute number of water molecules per interlayer space
# SHEET_WAT = 2

# Number of water molecules per unit cell
# UC_WAT = 0.1

# Percentage of water molecules from interlayer
# PERCENT_WAT = 5

# -----------------------------------------------------------------------------
# bash alias for used GROMACS version
# -----------------------------------------------------------------------------

GMX: gmx_mpi
File renamed without changes.
File renamed without changes.
Empty file.
38 changes: 38 additions & 0 deletions tests/ClayCodeTests/core/test_core.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from pathlib import Path

import pytest
from ClayCode import ArgsFactory, parser
from ClayCode.core.parsing import (
AddMolsArgs,
AnalysisArgs,
BuildArgs,
CheckArgs,
DataArgs,
EditArgs,
PlotArgs,
SiminpArgs,
)


@pytest.mark.parametrize(
("submodule", "argclass"),
[
("builder", BuildArgs),
# ("edit", EditArgs),
# ("check", CheckArgs),
("analysis", AnalysisArgs),
("siminp", SiminpArgs),
("data", DataArgs),
# ("addmols", AddMolsArgs),
("plot", PlotArgs),
],
)
def test_args_factory(submodule, argclass):
args = ArgsFactory()
parse_args = parser.parse_args(
[f"{submodule}", "-f", str(Path(__file__).parent / f"data/empty.yaml")]
)
with pytest.raises(SystemExit, match="2"):
args = args.init_subclass(parse_args)
args.__class__ == argclass
return args
Empty file.
Empty file.
Empty file.
Empty file.
File renamed without changes.

0 comments on commit f177280

Please sign in to comment.