ResSimpy.Nexus.NexusSimulator.NexusSimulator
- class ResSimpy.Nexus.NexusSimulator.NexusSimulator(origin: str | None = None, destination: str | None = None, root_name: str | None = None, nexus_data_name: str = 'data', write_times: bool = False, manual_fcs_tidy_call: bool = False, lazy_loading: bool = True)[source]
Bases:
SimulatorPublic Data Attributes:
model_filesnetworkReturns the location of the structured grid file.
Returns the default units.
Returns the run units.
Returns the new name for the FCS file without the fcs extension.
write_timesoriginal_fcs_file_pathroot_namedestinationInherited from
Simulatorstart_datewellspvtseparatorwaterequilrockrelpermvalveaquiferhydraulicsgasliftnetworkgridPass the grid information to the front end.
originmodel_locationReturns the location of the model.
model_filesMethods:
__init__([origin, destination, root_name, ...])Nexus simulator class.
Updates model values if the files are moved from a temp directory Replaces the first instance of temp/ in the file paths in the nexus simulation file paths.
get_simulation_status([from_startup])get_simulation_progress()get_users_linked_with_files()Returns the run and input unit formats for all the supplied models.
Checks for fluid types within a list of paths to models.
get_eos_details(surface_file)Gets all the information about an EOS from a Nexus model.
get_fluid_type(surface_file_name)Gets the fluid type for a single model from a surface file.
Returns the get_fluid_type method on the existing NexusSimulator instance.
Confirms that the output path has been set (used to stop accidental writing operations in the original directory).
set_output_path(path)Initialises the output to the declared output location.
update_file_value(file_path, token, new_value)Updates a value in a file if it is present and in the format {TOKEN} {VALUE}.
update_fcs_file_value(token, new_value[, ...])Updates a value in the FCS file.
comment_out_file_value(token, file_path)Comments out an uncommented line containing the specified token.
Returns the date format being used by the model formats used: ('MM/DD/YYYY', 'DD/MM/YYYY').
modify(operation, section, keyword, content)Generic modify method to modify part of the input deck.
get_content(section, keyword)Returns the requested input information.
Convert the structured grid info to a dictionary and pass it to the front end.
get_abs_structured_grid_path(filename)Returns the absolute path to the Structured Grid file.
Get the surface file path.
Populates nodes and connections from a surface file.
Inherited from
Simulatorget_fluid_type(surface_file_name)set_output_path(path)get_date_format()Returns date format as a string.
__repr__()Return repr(self).
__eq__(other)Return self==value.
- __init__(origin: str | None = None, destination: str | None = None, root_name: str | None = None, nexus_data_name: str = 'data', write_times: bool = False, manual_fcs_tidy_call: bool = False, lazy_loading: bool = True) None[source]
Nexus simulator class. Inherits from the Simulator super class.
- Parameters:
origin (Optional[str], optional) – file path to the fcs file. Defaults to None.
root_name (Optional[str], optional) – Root file name of the fcs. Defaults to None.
nexus_data_name (str, optional) – Folder name for the nexus data files to be stored in. Defaults to “data”.
write_times (bool, optional) – Sets whether the runcontrol file will expand the include files with time cards in. Defaults to True.
manual_fcs_tidy_call (bool, optional) – Determines whether fcs_tidy should be called - Currently not used. Defaults to False.
- run_control_file_path
file path to the run control file - derived from the fcs file
- Type:
Optional[str]
- __destination
output path for the simulation. Currently not used.
- Type:
Optional[str]
- date_format
Enum value representing the date format.
- Type:
- __original_fcs_file_path
Path to the original fcs file path supplied
- Type:
str
- __new_fcs_file_path
Where the new fcs will be saved to
- Type:
str
- __force_output
private attribute of force_output
- Type:
bool
- __origin
private attribute of origin. File path to the fcs file.
- Type:
str
- __root_name
private attribute of root_name. Root file name of the fcs.
- Type:
str
- __nexus_data_name
private attribute of nexus_data_name. Folder name for the nexus data files to be stored in.
- Type:
str
- __structured_grid_file_path
file path to the structured grid.
- Type:
Optional[str]
- __structured_grid_file
StructuredGridFile object representing the structured grid used in Nexus
- Type:
Optional[NexusGrid]
- __run_units
Unit system used in the Nexus model
- Type:
Optional[str]
- use_american_run_units
True if an American unit system is used equivalent to ‘ENGLISH’. False otherwise. For the RUN_UNITS keyword.
- Type:
bool
- use_american_input_units
True if an American unit system is used equivalent to ‘ENGLISH’. False otherwise. For the DEFAULT_UNITS keyword.
- Type:
bool
- __write_times
private attribute for write_times. Sets whether the runcontrol file will expand the include files with time cards in.
- Type:
bool
- __manual_fcs_tidy_call
private attribute for manual_fcs_tidy_call. Determines whether fcs_tidy should be called
- Type:
bool
- Raises:
ValueError – If the FCS file path is not given
- remove_temp_from_properties()[source]
Updates model values if the files are moved from a temp directory Replaces the first instance of temp/ in the file paths in the nexus simulation file paths.
- Raises:
ValueError – if any of [__structured_grid_file_path, __new_fcs_file_path, __surface_file_path] are None.
- property structured_grid_path
Returns the location of the structured grid file.
- property default_units
Returns the default units.
- property run_units
Returns the run units.
- property new_fcs_name
Returns the new name for the FCS file without the fcs extension.
- static get_check_run_input_units_for_models(models: list[str]) tuple[Optional[bool], Optional[bool]][source]
Returns the run and input unit formats for all the supplied models.
- Supported model formats:
RESQML type epc files ending in “.epc” Nexus files containing a line identifying the “RUN_UNITS” or “DEFAULT_UNITS”.
Supported units: ENGLISH, METRIC
- Parameters:
models (list[str]) – list of paths to supported reservoir models
- Raises:
ValueError – if a model in the list is using inconcistent run/default units
- Returns:
Tuple[Optional[Bool], Optional[Bool]] –
- If all units are consistent between models,
Returns (True, True) if ‘ft’ is the length unit in an epc or Nexus specifies “ENGLISH” as the (RUN_UNITS,DEFAULT_UNITS) respectively and False, False otherwise. Returns (None, None) if it can’t find a (RUN_UNITS, DEFAULT_UNITS) in the supplied files.
- static get_check_oil_gas_types_for_models(models: list[str]) str | None[source]
Checks for fluid types within a list of paths to models. Currently limited to checking for the first SURFACE network in a file.
- Parameters:
models (list[str]) – a list of paths to models to check for fluid types.
- Raises:
ValueError – If fluid types are inconsistent between models
- Returns:
Optional[str] – The fluid type used for the model for the first surface network
- static get_eos_details(surface_file: list[str]) str[source]
Gets all the information about an EOS from a Nexus model.
- Parameters:
surface_file (list[str]) – path to the surface file in a Nexus model
- Returns:
str – a concatenated string of EOS components
- static get_fluid_type(surface_file_name: str) str[source]
Gets the fluid type for a single model from a surface file.
- Parameters:
surface_file_name (str) – path to the surface file in a Nexus model
- Raises:
ValueError – if no fluid type is found within the provided file path
- Returns:
str – fluid type as one of [BLACKOIL, WATEROIL, GASWATER,] or the full details from an EOS model
- get_model_oil_type() str[source]
Returns the get_fluid_type method on the existing NexusSimulator instance.
- Raises:
ValueError – If no file path is provided for the surface file path
- Returns:
str – fluid type as one of [BLACKOIL, WATEROIL, GASWATER,] or the full details from an EOS model
- check_output_path() None[source]
Confirms that the output path has been set (used to stop accidental writing operations in the original directory).
- Raises:
ValueError – if the destination provided is set to None.
- set_output_path(path: str) None[source]
Initialises the output to the declared output location. If the file is a different directory to the origin path location the function will set the origin to the new destination.
- static update_file_value(file_path: str, token: str, new_value: str, add_to_start: bool = False) None[source]
Updates a value in a file if it is present and in the format {TOKEN} {VALUE}. If the token isn’t present, it will add the token + value to either the start or end of the file.
- Parameters:
file_path (str) – path to a file to update the token/value pair in
token (str) – Keyword token to find in the given file (e.g. KX)
new_value (str) – Value following the TOKEN to be replaced
add_to_start (bool, optional) – Inserts the token/value pair to the start of the file. Defaults to False.
- Raises:
ValueError – If no value is found after the token
- update_fcs_file_value(token, new_value, add_to_start=False)[source]
Updates a value in the FCS file.
- static comment_out_file_value(token: str, file_path: str) None[source]
Comments out an uncommented line containing the specified token.
- Parameters:
token (str) – Keyword token to find in the given file (e.g. KX)
file_path (str) – path to a file containing the token
- get_date_format() str[source]
Returns the date format being used by the model formats used: (‘MM/DD/YYYY’, ‘DD/MM/YYYY’).
- modify(operation: str, section: str, keyword: str, content: list[str])[source]
Generic modify method to modify part of the input deck. Operations are dependent on the section being modified.
- Parameters:
operation (str) – operation to perform on the section of the input deck (e.g. ‘merge’)
section (str) – file type from the input deck provided (e.g. RUNCONTROL)
keyword (str) – which keyword/token to find within the deck provided (e.g. TIME)
content (list[str]) – The content to modify using the above operation, represented as a list of strings with a new entry per line of the file
- Raises:
NotImplementedError – if the functionality is not yet implemented
- get_content(section: str, keyword: str) list[str] | None[source]
Returns the requested input information.
- Parameters:
section (str) – Section to retreive information from
keyword (str) – Keyword/token to retrieve the information for
- Raises:
NotImplementedError – if the functionality is not yet implemented
- Returns:
Union[list[str], None] – the requested information
- get_structured_grid_dict() dict[str, Any][source]
Convert the structured grid info to a dictionary and pass it to the front end.
- get_abs_structured_grid_path(filename: str)[source]
Returns the absolute path to the Structured Grid file.
- property grid: Grid | None
Pass the grid information to the front end.
- property model_location: str
Returns the location of the model.