Skip to content

Commit

Permalink
Merge pull request #55 from neutrons/pre-commit-config
Browse files Browse the repository at this point in the history
Configure pre-commit to do the static analysis
  • Loading branch information
Kvieta1990 authored Nov 15, 2024
2 parents 8de715d + df2c7cc commit 768aad2
Show file tree
Hide file tree
Showing 48 changed files with 6,901 additions and 7,462 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ __pycache__/
*.py[cod]
*$py.class

# conda package stuff
conda.recipe/

# C extensions
*.so

Expand Down
26 changes: 26 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
args: [--maxkb=8192]
- id: check-merge-conflict
- id: check-yaml
args: [--allow-multiple-documents]
exclude: "conda.recipe/meta.yaml"
- id: end-of-file-fixer
exclude: "tests/cis_tests/.*"
- id: trailing-whitespace
exclude: "tests/cis_tests/.*"
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.3
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
exclude: "tests/cis_tests/.*"
- id: ruff-format
exclude: "tests/cis_tests/.*"
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The original *StoG* program has been developed, in reverse chronological order,
* Matthew Tucker and Martin Dove (~2009)
* Spencer Howells (~1989)
* Jack Carpenter (prior to 1989)

A current state of the **StoG** program is kept in the `fortran` directory of this package.

This project was initially just a "sandbox" for taking the capabilities of **StoG** and migrating them over to the [Mantid Framework](https://github.com/mantidproject/mantid).
Expand All @@ -40,7 +40,7 @@ And [conda](https://docs.conda.io/en/latest/):

## Getting started

Once installed, you can access the packages classes that perform the function manipulation.
Once installed, you can access the packages classes that perform the function manipulation.

```python
import pystog
Expand Down Expand Up @@ -115,7 +115,7 @@ or with pipenv:

Using tox for all stages of testing (all python versions and linting), just run:
`tox`
NOTE: You must have the version of python installed to run a test suite against that verion via tox.
NOTE: You must have the version of python installed to run a test suite against that version via tox.
Recommended way to install python versions is `pyenv`

### Linting
Expand Down
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ignore:
- "./versioneer.py" # ignore versioneer from testing
- "./pystog/_version.py"
- "./pystog/_version.py"
4 changes: 1 addition & 3 deletions data/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Data files

Location of the data files used for generating g(r) from molecular dynamics,
Location of the data files used for generating g(r) from molecular dynamics,
data files for validating testing, and updated examples of using PyStoG

### Contents
Expand All @@ -10,5 +10,3 @@ data files for validating testing, and updated examples of using PyStoG
| `test_data` | Files for running the tests |
| `examples` | Script examples for using PyStoG |
| `lammps_inputs` | LAMMPS input files for generating g(r) data (used for making test data) |


3 changes: 1 addition & 2 deletions data/examples/argon_pystog.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{

"Files" : [
"Files" : [
{ "Filename" : "../data/argon.sq",
"ReciprocalFunction" : "S(Q)",
"Qmin" : 0.8,
Expand Down Expand Up @@ -44,4 +44,3 @@
"LorchFlag" : false,
"Outputs" : { "StemName" : "merged_argon" }
}

3 changes: 1 addition & 2 deletions data/examples/input.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{

"Files" : [
"Files" : [
{ "Filename" : "../data/co2_2k_original.sq",
"ReciprocalFunction" : "S(Q)",
"Qmin" : 0.8,
Expand All @@ -27,4 +27,3 @@
"LorchFlag" : "True",
"Outputs" : { "StemName" : "merged" }
}

12,002 changes: 6,001 additions & 6,001 deletions data/lammps_inputs/Ni.eam.fs

Large diffs are not rendered by default.

37 changes: 18 additions & 19 deletions data/lammps_inputs/in.argon
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
# ---------- Basic Variables ---------------------
# ---------- Basic Variables ---------------------
variable myStep equal 1000
variable number_of_steps equal 20000
variable dump_file string "dump.argon.lammpstrj"
variable rdf_file string "argon.gr"

variable T equal 86.56
variable rho_target equal 0.02138 # target 0.02138 atoms/ang^-3
variable natoms_target equal 50000
variable natoms_target equal 50000
variable vol_target equal ${natoms_target}/${rho_target}
variable L equal ${vol_target}^(1./3.)

variable supercell equal 1

# ---------- Initialize Simulation ---------------------
units real
dimension 3
boundary p p p
atom_style atomic
# ---------- Initialize Simulation ---------------------
units real
dimension 3
boundary p p p
atom_style atomic

# ---------- Create Atoms ---------------------
# ---------- Create Atoms ---------------------
region box block 0 ${L} 0 ${L} 0 ${L}
create_box 1 box
create_atoms 1 random ${natoms_target} 13725 box
mass 1 39.948
replicate ${supercell} ${supercell} ${supercell}

# ---------- Define Interatomic Potential ---------------------
# ---------- Define Interatomic Potential ---------------------
# J. Yarnell, M. Katz, R. Wenzel, and S. Koenig, Phys. Rev. A 7, 1973
variable eps_yarnell equal 0.238067
variable sig_yarnell equal 3.405
Expand All @@ -36,13 +36,13 @@ pair_style lj/cut 15.0
pair_coeff * * ${eps} ${sig}
pair_modify tail yes

# ---------- Run Minimization ---------------------
# ---------- Run Minimization ---------------------
thermo ${myStep}
thermo_style custom step pe lx ly lz press pxx pyy pzz pe temp
min_style cg
minimize 1e-25 1e-25 5000 10000
min_style cg
minimize 1e-25 1e-25 5000 10000

variable natoms equal "count(all)"
variable natoms equal "count(all)"
variable teng equal "pe"
variable length equal "lx"
variable ecoh equal "v_teng/v_natoms"
Expand All @@ -54,18 +54,18 @@ print "Number of atoms = ${natoms};"
print "Lattice constant (Angstoms) = ${length};"
print "Cohesive energy (eV) = ${ecoh};"

print "All done!"
print "All done!"
print "-------------------------------"
print ""

# ---------- Run Dynamics ---------------------
reset_timestep 0
# ---------- Run Dynamics ---------------------
reset_timestep 0
velocity all create 300.0 87979
dump 1 all atom ${myStep} ${dump_file}
fix 2 all nvt temp ${T} ${T} 100
run ${number_of_steps}

# ---------- Compute RDF ---------------------
# ---------- Compute RDF ---------------------
variable rho equal atoms/vol
variable natoms equal atoms
variable half_box_length equal "floor(vol^(1./3.)/2. - 2.)"
Expand All @@ -77,7 +77,7 @@ variable last_step equal ${number_of_steps}
variable Nfreq equal "v_last_step - v_first_step"
variable Nrepeat equal "v_Nfreq / v_myStep"

reset_timestep 0
reset_timestep 0
comm_modify cutoff ${half_box_length}
pair_style lj/cut ${rdf_cutoff}
pair_coeff * * 1.0 1.0
Expand All @@ -102,4 +102,3 @@ uncompute myRDF

clear
quit

43 changes: 21 additions & 22 deletions data/lammps_inputs/in.diamond
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
# ---------- Basic Variables ---------------------
# ---------- Basic Variables ---------------------
variable myStep equal 1000
variable number_of_steps equal 20000
variable dump_file string "dump.diamond.lammpstrj"
variable rdf_file string "diamond.gr"
variable supercell equal 15

# ---------- Initialize Simulation ---------------------
units metal
dimension 3
boundary p p p
atom_style atomic
# ---------- Initialize Simulation ---------------------
units metal
dimension 3
boundary p p p
atom_style atomic

# ---------- Create Atoms ---------------------
# ---------- Create Atoms ---------------------
lattice diamond 3.57
region box block 0 1 0 1 0 1 units lattice
create_box 1 box
create_atoms 1 box
replicate ${supercell} ${supercell} ${supercell}

# ---------- Define Interatomic Potential ---------------------
pair_style tersoff
# ---------- Define Interatomic Potential ---------------------
pair_style tersoff
pair_coeff * * ./SiC.tersoff C
neighbor 2.0 bin
neighbor 2.0 bin

mass 1 12.011
#neigh_modify delay 10 check yes
# ---------- Run Minimization ---------------------
#neigh_modify delay 10 check yes

# ---------- Run Minimization ---------------------
fix 1 all box/relax iso 0.0 vmax 0.001
thermo ${myStep}
thermo_style custom step pe lx ly lz press pxx pyy pzz pe
min_style cg
minimize 1e-25 1e-25 5000 10000
min_style cg
minimize 1e-25 1e-25 5000 10000

variable natoms equal "count(all)"
variable natoms equal "count(all)"
variable teng equal "pe"
variable length equal "lx"
variable ecoh equal "v_teng/v_natoms"
Expand All @@ -45,19 +45,19 @@ print "Number of atoms = ${natoms};"
print "Lattice constant (Angstoms) = ${length};"
print "Cohesive energy (eV) = ${ecoh};"

print "All done!"
print "All done!"
print "-------------------------------"
print ""

# ---------- Run Dynamics ---------------------
reset_timestep 0
# ---------- Run Dynamics ---------------------
reset_timestep 0
unfix 1
velocity all create 500.0 87979
dump 1 all atom ${myStep} ${dump_file}
fix 2 all nve
run ${number_of_steps}

# ---------- Compute RDF ---------------------
# ---------- Compute RDF ---------------------
variable rho equal atoms/vol
variable natoms equal atoms
variable half_box_length equal "floor(vol^(1./3.)/2. - 2.)"
Expand All @@ -69,7 +69,7 @@ variable last_step equal ${number_of_steps}
variable Nfreq equal "v_last_step - v_first_step"
variable Nrepeat equal "v_Nfreq / v_myStep"

reset_timestep 0
reset_timestep 0
comm_modify cutoff ${half_box_length}
pair_style lj/cut ${rdf_cutoff}
pair_coeff * * 1.0 1.0
Expand All @@ -94,4 +94,3 @@ uncompute myRDF

clear
quit

43 changes: 21 additions & 22 deletions data/lammps_inputs/in.nickel
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
# ---------- Basic Variables ---------------------
# ---------- Basic Variables ---------------------
variable myStep equal 1000
variable number_of_steps equal 20000
variable dump_file string "dump.nickel.lammpstrj"
variable rdf_file string "nickel.gr"
variable supercell equal 15

# ---------- Initialize Simulation ---------------------
units metal
dimension 3
boundary p p p
atom_style atomic
# ---------- Initialize Simulation ---------------------
units metal
dimension 3
boundary p p p
atom_style atomic

# ---------- Create Atoms ---------------------
# ---------- Create Atoms ---------------------
lattice fcc 3.5238
region box block 0 1 0 1 0 1 units lattice
create_box 1 box
create_atoms 1 box
replicate ${supercell} ${supercell} ${supercell}

# ---------- Define Interatomic Potential ---------------------
pair_style eam/alloy
# ---------- Define Interatomic Potential ---------------------
pair_style eam/alloy
pair_coeff * * ./Ni.eam.fs Ni
neighbor 2.0 bin
#neigh_modify delay 10 check yes
# ---------- Run Minimization ---------------------
neighbor 2.0 bin
#neigh_modify delay 10 check yes

# ---------- Run Minimization ---------------------
fix 1 all box/relax iso 0.0 vmax 0.001
thermo ${myStep}
thermo_style custom step pe lx ly lz press pxx pyy pzz pe
min_style cg
minimize 1e-25 1e-25 5000 10000
min_style cg
minimize 1e-25 1e-25 5000 10000

variable natoms equal "count(all)"
variable natoms equal "count(all)"
variable teng equal "pe"
variable length equal "lx"
variable ecoh equal "v_teng/v_natoms"
Expand All @@ -43,19 +43,19 @@ print "Number of atoms = ${natoms};"
print "Lattice constant (Angstoms) = ${length};"
print "Cohesive energy (eV) = ${ecoh};"

print "All done!"
print "All done!"
print "-------------------------------"
print ""

# ---------- Run Dynamics ---------------------
reset_timestep 0
# ---------- Run Dynamics ---------------------
reset_timestep 0
unfix 1
velocity all create 300.0 87979
dump 1 all atom ${myStep} ${dump_file}
fix 2 all nve
run ${number_of_steps}

# ---------- Compute RDF ---------------------
# ---------- Compute RDF ---------------------
variable rho equal atoms/vol
variable natoms equal atoms
variable half_box_length equal "floor(vol^(1./3.)/2. - 2.)"
Expand All @@ -67,7 +67,7 @@ variable last_step equal ${number_of_steps}
variable Nfreq equal "v_last_step - v_first_step"
variable Nrepeat equal "v_Nfreq / v_myStep"

reset_timestep 0
reset_timestep 0
comm_modify cutoff ${half_box_length}
pair_style lj/cut ${rdf_cutoff}
pair_coeff * * 1.0 1.0
Expand All @@ -92,4 +92,3 @@ uncompute myRDF

clear
quit

2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ help:
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Loading

0 comments on commit 768aad2

Please sign in to comment.