File IO
General Data Formats
The json file format is a direct JSON serialization of GasModels internal data model. As such, the json file format is intended to be a temporary storage format. GasModels does not maintain backwards compatibility with serializations of earlier versions of the Gas Models internal data model.
GasModels.parse_file — Function
parse_file(io)Parses the IOStream of a file into a GasModels data structure.
Matgas Data Files
The following method is the main methods for parsing Matgas data files:
GasModels.parse_matgas — Function
Parses the matgas data from either a filename or an IO object
We also provide the following (internal) helper methods:
GasModels._gasmodels_to_matgas_string — Method
write to matgas
GasModels._get_default — Function
Get a default value for dict entry
GasModels._matgas_to_gasmodels — Method
Converts a matgas dict into a PowerModels dict
GasModels._merge_generic_data! — Method
merges Matlab tables based on the table extension syntax
GasModels.parse_m_file — Method
parses matlab-formatted .m file
GasModels.parse_m_file — Method
parses matlab-formatted .m file
GasModels.parse_m_string — Method
parses matlab-format string
GasModels.parse_matgas — Method
Parses the matgas data from either a filename or an IO object
GasModels.write_matgas! — Method
writes data structure to matlab format
This format was designed to have a similar look a feel to the Matlab MatPower format (in the case of GasModels, we refer to it as the MatGas format), however, it standardizes around data requirements developed by the GasModels development team. It is largely stable. Additional fields for each component in the MatGas format can be incorporated using the Matlab extensions developed in InfrastructureModels.jl.
The top of the file contains global information about the network like its name, gas temperature, etc.
function mgc = gaslib-40
%% required global data
mgc.gas_specific_gravity = 0.6;
mgc.specific_heat_capacity_ratio = 1.4; % unitless
mgc.temperature = 273.15; % K
mgc.compressibility_factor = 0.8; % unitless
mgc.units = 'si';
%% optional global data (that was either provided or computed based on required global data)
mgc.gas_molar_mass = 0.01857; % kg/mol
mgc.R = 8.314; % J/(mol K)
mgc.base_length = 5000; % m (non-dimensionalization value)
mgc.base_pressure = 8101325; % Pa (non-dimensionalization value)
mgc.base_flow = 604; (non-dimensionalization value)
mgc.per_unit = false;
mgc.sound_speed = 312.8060Junction data is defined with the following tabular format
%% junction data
% id p_min p_max p_nominal junction_type status pipeline_name edi_id lat lon
mgc.junction = [
...
]The reader is referred to Matgas Format (.m) for detailed description on each column in the above table.
Pipeline data is defined with the following tabular format
%% pipe data
% id fr_junction to_junction diameter length friction_factor p_min p_max status
mgc.pipe = [
...
]The reader is referred to Matgas Format (.m) for detailed description on each column in the above table.
Compressor data is defined with the following tabular format
%% compressor data
% id fr_junction to_junction c_ratio_min c_ratio_max power_max flow_min flow_max inlet_p_min inlet_p_max outlet_p_min outlet_p_max status operating_cost directionality
mgc.compressor = [
...The reader is referred to Matgas Format (.m) for detailed description on each column in the above table.
Receipt data is defined with the following tabular format
%% receipt data
% id junction_id injection_min injection_max injection_nominal is_dispatchable status
mgc.receipt = [
...The reader is referred to Matgas Format (.m) for detailed description on each column in the above table.
Delivery data is defined with the following tabular format
%% delivery data
% id junction_id withdrawal_min withdrawal_max withdrawal_nominal is_dispatchable status
mgc.delivery = [
...The reader is referred to Matgas Format (.m) for detailed description on each column in the above table.
Parsing Transient Data
To run the transient formulations, apart from parsing the network file Matgas Format (.m), a time-series Transient Data Format (CSV) file has to be parsed. The following method provides a way to do so:
GasModels.parse_files — Function
Parses two files - a static file and a transient csv file and prepares the data object. The static file is the .m file and the transient file is a .csv file that contains the time-series data information. The function takes in the following keyword arguments: (i) total_time (defaults to 86400 seconds or 24 hours) - this is the total time for which transient optimization needs to be solved (ii) time_step (defaults to 3600 seconds or 1 hours) - this argument specifies the time discretization step (iii) spatial_discretization (defaults to 10000 m or 10 km) - this argument specifies the spatial discretization step (iv) additional_time (defaults to 21600 seconds or 6 hours) - this argument decides the time horizon that needs to be padded to the total time to in case the user wishes to perform a moving horizon transient optimization.
The data dictionary returned by the above function is a multi-network data dictionary with spatial discretization performed on pipelines with length greater than spatial_discretization keyword argument.