Skip to content

Commit

Permalink
Add copyright notice
Browse files Browse the repository at this point in the history
  • Loading branch information
haohanyang committed Nov 22, 2024
1 parent d2069b1 commit 8c72e62
Show file tree
Hide file tree
Showing 4 changed files with 521 additions and 144 deletions.
51 changes: 51 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
User Rights Notice

This software and related material (data and (or) documentation),
contained in or furnished in connection with PHREEQC, are made available
by the U.S. Geological Survey (USGS) to be used in the public interest
and in the advancement of science. You may, without any fee or cost,
use, copy, modify, or distribute this software, and any derivative works
thereof, and its supporting documentation, subject to the following
restrictions and understandings.

If you distribute copies or modifications of the software and related
material, make sure the recipients receive a copy of this notice and
receive or can get a copy of the original distribution. If the software
and (or) related material are modified and distributed, it must be
made clear that the recipients do not have the original and they must
be informed of the extent of the modifications. For example, modified
files must include a prominent notice stating the modifications made, the
author of the modifications, and the date the modifications were made.
This restriction is necessary to guard against problems introduced in the
software by others, reflecting negatively on the reputation of the USGS.

The software is public property and you therefore have the right to
the source code, if desired.

You may charge fees for distribution, warranties, and services provided
in connection with the software or derivative works thereof. The name
USGS can be used in any advertising or publicity to endorse or promote
any products or commercial entity using this software if specific
written permission is obtained from the USGS.

The user agrees to appropriately acknowledge the authors and the USGS
in publications that result from the use of this software or in products
that include this software in whole or in part.

Although this software program has been used by the U.S. Geological
Survey (USGS), no warranty, expressed or implied, is made by the USGS
or the U.S. Government as to the accuracy and functioning of the
program and related program material nor shall the fact of distribution
constitute any such warranty, and no responsibility is assumed by the
USGS in connection therewith.

The authors, the USGS, and the United States Government are not
obligated to provide the user with any support, consulting, training or
assistance of any kind with regard to the use, operation, and
performance of this software nor to provide the user with any updates,
revisions, new versions, or "bug fixes."

The user assumes all risk for any damages whatsoever resulting from
loss of use, data, or profits arising in connection with the access,
use, quality, or performance of this software.

23 changes: 18 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

Python bindings of [PHREEQC Version 3](https://www.usgs.gov/software/phreeqc-version-3)

The original C/C++ source code was downloaded from [IPhreeqc Modules](https://water.usgs.gov/water-resources/software/PHREEQC/iphreeqc-3.7.3-15968.tar.gz) made by USGS.

## Install
```
pip install phreeqc
Expand All @@ -12,10 +10,13 @@ pip install phreeqc
```py
from phreeqc import Phreeqc


p = Phreeqc()
p.load_database("phreeqc.dat")
p.run_string(
error_count = p.load_database("phreeqc.dat")

if error_count != 0:
raise RuntimeError("Failed to load database")

error_count = p.run_string(
"""
TITLE Example 2.--Temperature dependence of solubility
of gypsum and anhydrite
Expand Down Expand Up @@ -46,6 +47,18 @@ END
"""
)

if error_count != 0:
raise RuntimeError("Failed to run string")

selected_output = p.get_selected_output()

print(selected_output)

```
## License
This project provides Python bindings for the iphreeqc software. The bindings are distributed under the [MIT License](/LICENSE), which applies to the Python and C++ binding code in this repository.

However, please note:

IPHREEQC, the underlying software to which these bindings provide access, is made available by the U.S. Geological Survey (USGS) under the terms described in its [User Rights Notice](/NOTICE). You can also find the full text of the license in the iphreeqc source or documentation.
By using this project, you agree to comply with the terms outlined in the iphreeqc license as well as the MIT license for the Python bindings.
20 changes: 16 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,26 @@ namespace py = pybind11;
class _Phreeqc : public IPhreeqc
{
public:
void _AccumulateLine(const char *line)
bool _AccumulateLine(const char *line)
{
auto result = AccumulateLine(line);
if (result == VR_OUTOFMEMORY)
{
throw std::runtime_error("Failure, Out of memory");
return false;
}
return true;
}

bool _SetCurrentSelectedOutputUserNumber(int n)
{
auto result = SetCurrentSelectedOutputUserNumber(n);
if (result == VR_INVALIDARG)
{
return false;
}
return true;
}

const std::variant<long, double, std::string> _GetSelectedOutputValue(int row, int col)
{

Expand Down Expand Up @@ -135,7 +147,7 @@ PYBIND11_MODULE(_iphreeqc, m)
.def("run_accumulated", &_Phreeqc::RunAccumulated)
.def("run_file", &_Phreeqc::RunFile)
.def("run_string", &_Phreeqc::RunString)
.def("set_current_selected_output_user_number", &_Phreeqc::SetCurrentSelectedOutputUserNumber)
.def("set_current_selected_output_user_number", &_Phreeqc::_SetCurrentSelectedOutputUserNumber)
.def("set_dump_file_name", &_Phreeqc::SetDumpFileName)
.def("set_dump_file_on", &_Phreeqc::SetDumpFileOn)
.def("set_dump_string_on", &_Phreeqc::SetDumpStringOn)
Expand All @@ -153,5 +165,5 @@ PYBIND11_MODULE(_iphreeqc, m)
.def("set_selected_output_file_on", &_Phreeqc::SetSelectedOutputFileOn)
.def("set_selected_output_string_on", &_Phreeqc::SetSelectedOutputStringOn);

m.attr("__version__") = "0.1.2";
m.attr("__version__") = "0.2.0";
}
Loading

0 comments on commit 8c72e62

Please sign in to comment.