Skip to content

Commit

Permalink
Merge pull request #20 from MJCliffe/Live
Browse files Browse the repository at this point in the history
Merge all the changes from live into joss
  • Loading branch information
MJCliffe authored Oct 18, 2023
2 parents d1a0d90 + fd458ab commit ec101ec
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 5 deletions.
3 changes: 2 additions & 1 deletion paper/paper.bib
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ @article{ELATE2016
number={27},
pages={275201},
year={2016},
doi = {10.1088/0953-8984/28/27/275201},
publisher={IOP Publishing}
}

Expand All @@ -101,7 +102,7 @@ @book{Giacovazzo2011
% ? unused Number of pages ("842")
@article{Goodwin2008a,
title = {Large Negative Linear Compressibility of {{Ag3}}[{{Co}}({{CN}})6].},
title = {Large Negative Linear Compressibility of {{Ag{{$_3$}}}}[{{Co}}({{CN}}){{$_6$}}].},
author = {Goodwin, Andrew L and Keen, David A and Tucker, Matthew G},
year = {2008},
month = dec,
Expand Down
2 changes: 1 addition & 1 deletion paper/paper.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The strain matrix is then diagonalised, to yield the principal strains (eigenval

These matched and sorted strain eigenvalues are then fitted to equations of state appropriate to the data type. All data types are first fitted linearly. Pressure datasets, which are highly non-linear, are additionally fitted to the widely used empirical equation-of-state: $\epsilon(p) = \epsilon_0 + \lambda (p - p_c)^\nu$ [@Goodwin2008a]. For electrochemical datasets, where datasets are non-linear but analytic equations-of-state are not widely used, the data are fitted by Chebyshev polynomials with an appropriate regularisation procedure.

Linear fits are carried out on volumetric data, with additional fitting carried out for pressure datasets to the Birch-Murnaghan equations of state (second order, third order, and third order with critical pressure correction) [@Birch1947; @Sata2002] and for electrochemical datasets using Chebyshev polynomials. The errors in calculated parameters and their derivatives with respect to the stimuli (i.e., compressibilities) are calculated using the residuals of the fits, as propagation of crystallographic errors through to the strain is not in general well-defined. Errors in the stimulus are used solely to weight the relative importance of data points.
Linear fits are carried out on volumetric data, with additional fitting carried out for pressure datasets to the Birch-Murnaghan equations of state (second order, third order, and third order with critical pressure correction) [@Birch1947; @Sata2002] and for electrochemical datasets using Chebyshev polynomials. The errors in calculated parameters and their derivatives with respect to the stimuli (i.e., compressibilities) are calculated using the residuals of the fits, as the propagation of the errors in the unit cell parameters through to the errors in the diagonalised strain is not well-defined in general. Errors in the stimulus are used solely to weight the relative importance of data points.

The output page consists of a number of tables of physically meaningful coefficients and interactive graphics [@plotlytechnologiesincCollaborativeDataScience2015] showing the stimuli dependence of the principal strains, their derivatives (for pressure and electrochemical data), and an indicatrix represention of the expansivity/compressibility.

Expand Down
2 changes: 1 addition & 1 deletion src/PASCal/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def _set_named_coeffs(self):
[d[2] if len(d) > 2 else "n/a" for d in sigmas], dtype=object
)
self.named_coefficients["PcCoef"] = np.array(
[0.0, 0.0, self.options.pc_val]
[0.0, 0.0, self.options.pc_val if self.options.pc_val else 0.0]
)
self.named_coefficients["CalPress"] = np.zeros(
(len(self.volume_fits), len(self.cell_volumes))
Expand Down
9 changes: 7 additions & 2 deletions src/PASCal/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,13 @@ def from_dict(options: Dict[str, Any]) -> "Options":

if options.get("data_type"):
options["data_type"] = PASCalDataType[options["data_type"].upper()]
if options.get("pc_val"):
options["pc_val"] = float(options["pc_val"])
if options.get("pc_val") is not None:
if not options.get("pc_val"):
options["pc_val"] = None
else:
options["pc_val"] = float(options["pc_val"])
if options.get("pc_val") is None:
options["use_pc"] = False
if options.get("deg_poly_strain"):
options["deg_poly_strain"] = int(options["deg_poly_strain"])
if options.get("deg_poly_vol"):
Expand Down
45 changes: 45 additions & 0 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,33 @@ def test_q_sample_data(
), "Volumes table failed"


def test_p_no_pc_sample_data(
client,
sample_p,
parser,
):
post_parameters = {
"DataType": "Pressure",
"EulerianStrain": "True",
"FiniteStrain": "True",
"DegPolyCap": "",
"DegPolyVol": "",
"UsePc": "False",
"PcVal": "",
"data": sample_p,
}

response = client.post("/output", data=post_parameters)
assert response.status_code == 200

html_response = [d for d in response.response]
assert len(html_response) == 1

soup = parser(html_response[0])
tables = soup.find_all("table")
assert len(tables) == 7


def test_parse_options():
from PASCal.options import Options, PASCalDataType

Expand All @@ -227,3 +254,21 @@ def test_parse_options():
assert options.deg_poly_strain == 12
assert options.deg_poly_vol == 10
assert not options.finite_strain

form_example = {
"DataType": "Temperature",
"UsePc": "False",
"PcVal": "",
"EulerianStrain": "True",
"DegPolyVol": "10",
"DegPolyCap": "12",
"FiniteStrain": "False",
}
options = Options.from_form(form_example)
assert options.data_type == PASCalDataType.TEMPERATURE
assert options.use_pc is False
assert options.pc_val is None
assert options.eulerian_strain
assert options.deg_poly_strain == 12
assert options.deg_poly_vol == 10
assert not options.finite_strain

0 comments on commit ec101ec

Please sign in to comment.