|
| 1 | +Getting Started |
| 2 | +=============== |
| 3 | + |
| 4 | +Web Interface |
| 5 | +------------- |
| 6 | + |
| 7 | +A web interface is available at `gtp.scientificwebservices.com/geophires <https://gtp.scientificwebservices.com/geophires>`__. |
| 8 | + |
| 9 | +The short URL `bit.ly/geophires <https://bit.ly/geophires>`__ redirects to the same location. |
| 10 | + |
| 11 | +Installation |
| 12 | +------------ |
| 13 | + |
| 14 | +Pip Package |
| 15 | +^^^^^^^^^^^ |
| 16 | + |
| 17 | +If you do not need to view or edit GEOPHIRES-X source code, you can consume GEOPHIRES-X as a regular, non-editable python package:: |
| 18 | + |
| 19 | + pip3 install https://github.com/NREL/GEOPHIRES-X/archive/main.zip |
| 20 | + |
| 21 | + |
| 22 | +.. (Eventually package will be published to PyPi, enabling ``pip install geophires-x``) |
| 23 | +
|
| 24 | +
|
| 25 | +Editable Installation (Recommended) |
| 26 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 27 | + |
| 28 | +An editable installation is recommended for most users. It will allow you to run GEOPHIRES-X locally, |
| 29 | +view its Python files in an IDE or text editor, |
| 30 | +and create your own extensions as described in `How to extend GEOPHIRES-X <docs/How-to-extend-GEOPHIRES-X.md#how-to-extend-geophires-x>`__. |
| 31 | + |
| 32 | +Prerequisites: |
| 33 | + |
| 34 | +1. Python 3.8+: You must have Python 3.8 or later installed on your machine. Python can be downloaded at `python.org/downloads <https://www.python.org/downloads/>`__. (On Ubuntu: ``alias python=python3`` if not aliased already.) |
| 35 | +2. `Git <https://git-scm.com/book/en/v2/Getting-Started-Installing-Git>`__ |
| 36 | +3. Virtual environment (aka ``virtualenv``): `Install virtual environment on your machine <https://virtualenv.pypa.io/en/latest/installation.html#via-pip>`__ if you don't have it already |
| 37 | +4. On Windows, you will need Admin privileges (required to successfully activate the virtual environment) |
| 38 | + |
| 39 | +Steps: |
| 40 | + |
| 41 | +1. Open a command line (i.e. Terminal on Mac, PowerShell on Windows) |
| 42 | +2. Create a directory for GEOPHIRES:: |
| 43 | + |
| 44 | + mkdir my-geophires-project |
| 45 | + cd my-geophires-project |
| 46 | + |
| 47 | +3. Create a virtual environment:: |
| 48 | + |
| 49 | + python -m venv venv |
| 50 | + |
| 51 | +4. Source the virtual environment: |
| 52 | + |
| 53 | + - Windows:: |
| 54 | + |
| 55 | + venv\Scripts\activate |
| 56 | + |
| 57 | + - macOS/Linux:: |
| 58 | + |
| 59 | + source venv/bin/activate |
| 60 | + |
| 61 | +5. Install the ``geophires-x`` package:: |
| 62 | + |
| 63 | + pip3 install -e git+https://github.com/NREL/GEOPHIRES-X.git#egg=geophires-x --src . |
| 64 | + |
| 65 | +6. Run on an example file:: |
| 66 | + |
| 67 | + cd geophires-x |
| 68 | + cd tests |
| 69 | + cd examples |
| 70 | + python -mgeophires_x example1.txt |
| 71 | + |
| 72 | +7. View and edit source code by opening the ``my-geophires-project/`` directory in an IDE or editor such as `PyCharm <https://www.jetbrains.com/pycharm/>`__, `Spyder <https://www.spyder-ide.org/>`__, or `Visual Studio Code <https://code.visualstudio.com/>`__. The GEOPHIRES-X source code will be located in the ``my-geophires-project/geophires-x`` directory. You can add your own python files in ``my-geophires-x/`` that use the source as a module as shown below. |
| 73 | + |
| 74 | +To update the editable installation with the latest GEOPHIRES version:: |
| 75 | + |
| 76 | + cd geophires-x |
| 77 | + git pull |
| 78 | + # resolve merge conflicts, if any |
| 79 | + pip install -e . |
| 80 | + |
| 81 | + |
| 82 | + |
| 83 | +Usage |
| 84 | +----- |
| 85 | + |
| 86 | +Python |
| 87 | +^^^^^^ |
| 88 | + |
| 89 | +Example usage in Python: |
| 90 | + |
| 91 | +.. code:: python |
| 92 | +
|
| 93 | + from geophires_x_client import GeophiresXClient |
| 94 | + from geophires_x_client.geophires_input_parameters import GeophiresInputParameters |
| 95 | +
|
| 96 | + client = GeophiresXClient() |
| 97 | + result = client.get_geophires_result( |
| 98 | + GeophiresInputParameters({ |
| 99 | + "Gradient 1": "69", |
| 100 | + "Reservoir Depth": "5", |
| 101 | + "End-Use Option": "1", |
| 102 | + "Power Plant Type": "4" |
| 103 | + }) |
| 104 | + ) |
| 105 | +
|
| 106 | + with open(result.output_file_path, 'r') as f: |
| 107 | + print(f.read()) |
| 108 | +
|
| 109 | +If you followed the editable installation example above, put this code in ``my-geophires-project/main.py``, then run:: |
| 110 | + |
| 111 | + python main.py |
| 112 | + |
| 113 | +You will then see output including a case report:: |
| 114 | + |
| 115 | + (venv) ➜ my-geophires-project python main.py |
| 116 | + No valid plant outlet pressure provided. GEOPHIRES will assume default plant outlet pressure (100 kPa) |
| 117 | + No valid plant outlet pressure provided. GEOPHIRES will assume default plant outlet pressure (100 kPa) |
| 118 | + |
| 119 | + ***************** |
| 120 | + ***CASE REPORT*** |
| 121 | + ***************** |
| 122 | + |
| 123 | + Simulation Metadata |
| 124 | + ---------------------- |
| 125 | + GEOPHIRES Version: 3.4.42 |
| 126 | + Simulation Date: 2024-07-08 |
| 127 | + Simulation Time: 10:07 |
| 128 | + Calculation Time: 0.047 sec |
| 129 | + |
| 130 | + ***SUMMARY OF RESULTS*** |
| 131 | + |
| 132 | + End-Use Option: Electricity |
| 133 | + Average Net Electricity Production: 23.94 MW |
| 134 | + Electricity breakeven price: 5.04 cents/kWh |
| 135 | + |
| 136 | + [...] |
| 137 | + |
| 138 | + |
| 139 | +You may also pass parameters as a text file: |
| 140 | + |
| 141 | +.. code:: python |
| 142 | +
|
| 143 | + from pathlib import Path |
| 144 | + from geophires_x_client import GeophiresXClient |
| 145 | + from geophires_x_client.geophires_input_parameters import GeophiresInputParameters |
| 146 | +
|
| 147 | + # https://github.com/NREL/GEOPHIRES-X/blob/main/tests/examples/example1.txt |
| 148 | + example_file_path = Path('geophires-x/tests/examples/example1.txt').absolute() |
| 149 | +
|
| 150 | + client = GeophiresXClient() |
| 151 | + result = client.get_geophires_result( |
| 152 | + GeophiresInputParameters(from_file_path=example_file_path) |
| 153 | + ) |
| 154 | +
|
| 155 | + with open(result.output_file_path, 'r') as f: |
| 156 | + print(f.read()) |
| 157 | +
|
| 158 | +
|
| 159 | +`test_geophires_x.py <tests/test_geophires_x.py>`__ has additional examples of how to consume and call `GeophiresXClient <src/geophires_x_client/__init__.py#L14>`__. |
| 160 | + |
| 161 | + |
| 162 | +Command Line |
| 163 | +^^^^^^^^^^^^ |
| 164 | + |
| 165 | +If you installed with pip (editable or non-), you may run GEOPHIRES from the command line, passing your input file as an argument:: |
| 166 | + |
| 167 | + python -mgeophires_x my_geophires_input.txt |
| 168 | + |
| 169 | +You may also optionally pass the output file as well:: |
| 170 | + |
| 171 | + python -mgeophires_x my_geophires_input.txt my_geophires_result.out |
| 172 | + |
| 173 | +(If you do not pass an output file argument a default name will be used.) |
0 commit comments