Skip to content

Commit

Permalink
Added Example for plexos
Browse files Browse the repository at this point in the history
  • Loading branch information
pesap committed Aug 23, 2024
1 parent e4ac227 commit 4f50bbb
Show file tree
Hide file tree
Showing 3 changed files with 264 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/r2x/parser/plexos.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,8 @@ def _construct_interfaces(self, default_model=TransmissionInterface):
return

def _select_model_name(self):
# TODO(pesap): Add fail mechanism
# https://github.com/NREL/R2X/issues/10
query = f"""
select obj.name
from t_object as obj
Expand Down
259 changes: 259 additions & 0 deletions tests/data/2-bus_example.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
<MasterDataSet xmlns="http://tempuri.org/MasterDataSet.xsd">
<t_category>
<category_id>1</category_id>
<class_id>1</class_id>
<rank>0</rank>
<name>-</name>
</t_category>
<t_category>
<category_id>2</category_id>
<class_id>2</class_id>
<rank>0</rank>
<name>-</name>
</t_category>

<t_class>
<class_id>1</class_id>
<name>System</name>
<class_group_id>1</class_group_id>
<is_enabled>true</is_enabled>
<lang_id>1</lang_id>
<description>The integrated energy system</description>
</t_class>
<t_class>
<class_id>2</class_id>
<name>Generator</name>
<class_group_id>2</class_group_id>
<is_enabled>true</is_enabled>
<lang_id>22</lang_id>
<description>Generating unit, or collection of like generating units</description>
</t_class>
<t_class>
<class_id>4</class_id>
<name>Fuel</name>
<class_group_id>2</class_group_id>
<is_enabled>true</is_enabled>
<lang_id>18</lang_id>
<description>Fuel for a thermal generating unit</description>
</t_class>
<t_data>
<data_id>1</data_id>
<membership_id>43</membership_id>
<property_id>47</property_id>
<value>100</value>
<uid>169864276</uid>
</t_data>
<t_data>
<data_id>2</data_id>
<membership_id>47</membership_id>
<property_id>46</property_id>
<value>1</value>
<uid>169864277</uid>
</t_data>
<t_data>
<data_id>3</data_id>
<membership_id>47</membership_id>
<property_id>47</property_id>
<value>100</value>
<uid>169864278</uid>
</t_data>
<t_data>
<data_id>4</data_id>
<membership_id>47</membership_id>
<property_id>47</property_id>
<value>120</value>
<uid>169864279</uid>
</t_data>
<t_class>
<class_id>78</class_id>
<name>Scenario</name>
<class_group_id>11</class_group_id>
<is_enabled>true</is_enabled>
<lang_id>35</lang_id>
<description>Data scenario</description>
</t_class>
<t_membership>
<membership_id>43</membership_id>
<parent_class_id>1</parent_class_id>
<parent_object_id>1</parent_object_id>
<collection_id>1</collection_id>
<child_class_id>2</child_class_id>
<child_object_id>20</child_object_id>
</t_membership>
<t_membership>
<membership_id>44</membership_id>
<parent_class_id>1</parent_class_id>
<parent_object_id>1</parent_object_id>
<collection_id>261</collection_id>
<child_class_id>22</child_class_id>
<child_object_id>21</child_object_id>
</t_membership>
<t_membership>
<membership_id>45</membership_id>
<parent_class_id>1</parent_class_id>
<parent_object_id>1</parent_object_id>
<collection_id>261</collection_id>
<child_class_id>22</child_class_id>
<child_object_id>22</child_object_id>
</t_membership>
<t_membership>
<membership_id>46</membership_id>
<parent_class_id>1</parent_class_id>
<parent_object_id>1</parent_object_id>
<collection_id>196</collection_id>
<child_class_id>19</child_class_id>
<child_object_id>23</child_object_id>
</t_membership>
<t_membership>
<membership_id>47</membership_id>
<parent_class_id>1</parent_class_id>
<parent_object_id>1</parent_object_id>
<collection_id>1</collection_id>
<child_class_id>2</child_class_id>
<child_object_id>24</child_object_id>
</t_membership>
<t_membership>
<membership_id>52</membership_id>
<parent_class_id>2</parent_class_id>
<parent_object_id>20</parent_object_id>
<collection_id>12</collection_id>
<child_class_id>22</child_class_id>
<child_object_id>21</child_object_id>
</t_membership>
<t_membership>
<membership_id>53</membership_id>
<parent_class_id>1</parent_class_id>
<parent_object_id>1</parent_object_id>
<collection_id>39</collection_id>
<child_class_id>4</child_class_id>
<child_object_id>25</child_object_id>
</t_membership>
<t_membership>
<membership_id>54</membership_id>
<parent_class_id>2</parent_class_id>
<parent_object_id>24</parent_object_id>
<collection_id>7</collection_id>
<child_class_id>4</child_class_id>
<child_object_id>25</child_object_id>
</t_membership>
<t_membership>
<membership_id>55</membership_id>
<parent_class_id>2</parent_class_id>
<parent_object_id>24</parent_object_id>
<collection_id>12</collection_id>
<child_class_id>22</child_class_id>
<child_object_id>22</child_object_id>
</t_membership>
<t_membership>
<membership_id>56</membership_id>
<parent_class_id>22</parent_class_id>
<parent_object_id>21</parent_object_id>
<collection_id>264</collection_id>
<child_class_id>19</child_class_id>
<child_object_id>23</child_object_id>
</t_membership>
<t_membership>
<membership_id>57</membership_id>
<parent_class_id>22</parent_class_id>
<parent_object_id>22</parent_object_id>
<collection_id>264</collection_id>
<child_class_id>19</child_class_id>
<child_object_id>23</child_object_id>
</t_membership>
<t_membership>
<membership_id>58</membership_id>
<parent_class_id>1</parent_class_id>
<parent_object_id>1</parent_object_id>
<collection_id>707</collection_id>
<child_class_id>80</child_class_id>
<child_object_id>26</child_object_id>
</t_membership>
<t_membership>
<membership_id>59</membership_id>
<parent_class_id>1</parent_class_id>
<parent_object_id>1</parent_object_id>
<collection_id>700</collection_id>
<child_class_id>78</child_class_id>
<child_object_id>27</child_object_id>
</t_membership>
<t_membership>
<membership_id>60</membership_id>
<parent_class_id>80</parent_class_id>
<parent_object_id>26</parent_object_id>
<collection_id>708</collection_id>
<child_class_id>78</child_class_id>
<child_object_id>27</child_object_id>
</t_membership>
<t_object>
<object_id>1</object_id>
<class_id>1</class_id>
<name>System</name>
<category_id>1</category_id>
<description>the system object</description>
<GUID>98bd24fd-e92b-4738-92d4-3f03a8a09cc3</GUID>
</t_object>
<t_object>
<object_id>20</object_id>
<class_id>2</class_id>
<name>SolarPV_01</name>
<category_id>2</category_id>
<description />
<GUID>0b6116f3-28c3-4cb1-a3c9-bad59585db4e</GUID>
</t_object>
<t_object>
<object_id>21</object_id>
<class_id>22</class_id>
<name>node_01</name>
<category_id>22</category_id>
<description />
<GUID>b4652dbe-a597-44e5-a36e-b1c9d53e0b18</GUID>
</t_object>
<t_object>
<object_id>22</object_id>
<class_id>22</class_id>
<name>node_02</name>
<category_id>22</category_id>
<description />
<GUID>f926e130-4719-4249-bf32-f0dded4a93bd</GUID>
</t_object>
<t_object>
<object_id>23</object_id>
<class_id>19</class_id>
<name>region_1</name>
<category_id>19</category_id>
<description />
<GUID>5db56664-18a1-4e9e-a9f2-31fc816d8dda</GUID>
</t_object>
<t_object>
<object_id>24</object_id>
<class_id>2</class_id>
<name>ThermalCC_01</name>
<category_id>2</category_id>
<description />
<GUID>6659cbb9-2851-483c-a5bc-1d03659f2ca2</GUID>
</t_object>
<t_object>
<object_id>25</object_id>
<class_id>4</class_id>
<name>gas</name>
<category_id>4</category_id>
<description />
<GUID>71917e41-f45b-44ad-81db-d88efcc34aea</GUID>
</t_object>
<t_object>
<object_id>26</object_id>
<class_id>80</class_id>
<name>main_model</name>
<category_id>80</category_id>
<description />
<GUID>baec2eea-16a4-4f3a-bd6f-c24664b0069e</GUID>
</t_object>
<t_object>
<object_id>27</object_id>
<class_id>78</class_id>
<name>MoreCapacity</name>
<category_id>78</category_id>
<description />
<GUID>331cc8ab-bff8-4416-91d2-748012abef75</GUID>
</t_object>
</MasterDataSet>
4 changes: 3 additions & 1 deletion tests/test_plexos_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from r2x.parser.handler import get_parser_data
from r2x.parser.plexos import PlexosParser

DB_NAME = "plexos_example.xml"
DB_NAME = "2-bus_example.xml"
MODEL_NAME = "main_model"


@pytest.fixture
Expand All @@ -14,6 +15,7 @@ def plexos_scenario(tmp_path, data_folder):
input_model="plexos",
run_folder=data_folder,
output_folder=tmp_path,
model=MODEL_NAME,
solve_year=2035,
weather_year=2012,
fmap={"xml_file": {"fname": DB_NAME, "model": "default"}},
Expand Down

0 comments on commit 4f50bbb

Please sign in to comment.