From 447b9c53ede7a06c22b23563a1be75a590f8808a Mon Sep 17 00:00:00 2001 From: Matthew Evans <7916000+ml-evs@users.noreply.github.com> Date: Thu, 12 Oct 2023 10:58:06 +0100 Subject: [PATCH 1/5] Fix form parsing edge-case for critical pressure (#18) * Better handling of non-Pc case * Improve tests for non-Pc pressure case --- src/PASCal/core.py | 2 +- src/PASCal/options.py | 9 +++++++-- tests/test_app.py | 45 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 3 deletions(-) diff --git a/src/PASCal/core.py b/src/PASCal/core.py index 87d764e..3f6f6f7 100644 --- a/src/PASCal/core.py +++ b/src/PASCal/core.py @@ -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)) diff --git a/src/PASCal/options.py b/src/PASCal/options.py index 121e9d4..797ee40 100644 --- a/src/PASCal/options.py +++ b/src/PASCal/options.py @@ -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"): diff --git a/tests/test_app.py b/tests/test_app.py index 1c376e9..6d6963c 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -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 @@ -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 From 6cb840b737d9cebd54f56a07db3bb71c579f648e Mon Sep 17 00:00:00 2001 From: Matt Cliffe Date: Sun, 15 Oct 2023 09:05:12 +0100 Subject: [PATCH 2/5] typo in citation --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 442ffde..6220f5a 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,9 @@ PASCal as designed might not be the most appropriate method for full analysis of ## How to cite -A paper summarising the original motivation and theory behind PASCal is published at [J. Appl. Cryst. (2012). 45, 1321-1329](https://doi.org/10.1107/S0021889812043026) ([arXiv](http://arxiv.org/pdf/1204.3007.pdf)). +If you use PASCal v2+ in a publication, please cite the latest published description of the software: [Lertkiattrakul *et al.*, Journal of Open Source Software (2023)](https://joss.theoj.org/papers/3bfe66743c9a86f34d3c1b2f17906261). -If you use PASCal v2+ in a publication, please cite the latest published description of the software: [Lertkiattraku *et al.*, Journal of Open Source Software (2023)](https://joss.theoj.org/papers/3bfe66743c9a86f34d3c1b2f17906261). +A paper summarising the original motivation and theory behind PASCal is published at [J. Appl. Cryst. (2012). 45, 1321-1329](https://doi.org/10.1107/S0021889812043026) ([arXiv](http://arxiv.org/pdf/1204.3007.pdf)). # Quick start From 1a9c23ee652c6d9d94abcb768d2e83aaca6dda04 Mon Sep 17 00:00:00 2001 From: Matt Cliffe Date: Wed, 18 Oct 2023 08:01:21 +0100 Subject: [PATCH 3/5] added DOI for ELATE --- paper/paper.bib | 1 + 1 file changed, 1 insertion(+) diff --git a/paper/paper.bib b/paper/paper.bib index 8e02b29..31520ae 100644 --- a/paper/paper.bib +++ b/paper/paper.bib @@ -84,6 +84,7 @@ @article{ELATE2016 number={27}, pages={275201}, year={2016}, + doi = {10.1088/0953-8984/28/27/275201}, publisher={IOP Publishing} } From 2305f1cd4e5d1088e73a3f604adc0984eeb934d8 Mon Sep 17 00:00:00 2001 From: Matt Cliffe Date: Wed, 18 Oct 2023 08:10:30 +0100 Subject: [PATCH 4/5] description of error propagation improved --- paper/paper.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paper/paper.md b/paper/paper.md index 9521cae..650b46d 100644 --- a/paper/paper.md +++ b/paper/paper.md @@ -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. From fd458abe77ebcee1465b7316a99eee15578ebcfe Mon Sep 17 00:00:00 2001 From: Matt Cliffe Date: Wed, 18 Oct 2023 08:11:48 +0100 Subject: [PATCH 5/5] Subscripts in paper title --- paper/paper.bib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paper/paper.bib b/paper/paper.bib index 31520ae..582d38c 100644 --- a/paper/paper.bib +++ b/paper/paper.bib @@ -102,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,