-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Help wanted, the external file #53
Comments
This seems like a TRNSYS question. Please refer to the TRNSYS documentation on how to use weather readers. As for any issues with Trnsystor, please provide the full code (with comments) to help me help you. |
from trnsystor import TrnsysModel import type9e for the weather_data, the xmltmf file just directly saving from the trnsys studioweather_xml = "./all_xml/Type9e.xmltmf" weather_model = TrnsysModel.from_xml(weather_xml) changing of the parameters for the txt file I just need to load, this setting is working in trnsys studioweather_model.parameters["Mode"] = 4 using type 65c to plot the weather information,type65_xml = "./all_xml/Type65c.xmltmf" #connected between those two model simulation cardcc = ControlCards.all() deck_file = Deck(name='mytest', control_cards=cc, author='gaoyuan') list_models = [weather_model, monitor_test] deck_file.update_models(list_models) deck_file.save('my_project.dck') running simulation through dck filesubprocess.call(r'"D:\TRNSYS18\Exe\TrnEXE64.exe" "my_project.dck"', cwd=r'C:\Users\asus\Desktop\trnsys') Here is my code file, I am a little bit confused for the introduction of external_files for the model, especially for type9e model. Since I could not find an coding example for how to deal with the external_files of trnsys model, I just change the XML text for the path of external_files, but still not work. |
I think the most difficult part is for the external_files in trnsystor. I could not find out how to deal with this part. The doc seems a little bit confusing to me and there is no coding example. |
Thank you for sharing the example; this was very helpfull. The path of an external file must be set weather_model.external_files["Input_file_name"] = "tests/input_files/US-CO-Boulder-94018.tm2" Btw, why don't you use the Type15-2 to read the weather data? |
Thanks a lot for your help, I may use the real measured data to replace the other data, so I used the .txt file. Currently, I change to the type15-2, however, it just raises the KeyError when I modify my coding, here is the result. weather_xml = "./all_xml/Type15-2.xmltmf" weather_model = TrnsysModel.from_xml(weather_xml) weather_model.external_files["Input_file_name"].value = "C:/Users/asus/Desktop/trnsys/Weather/US-TMY2/US-CA-San-Francisco-23234.tm2" I rebuild the xmltmf file from trnsys 18, and try again, but it is till not working. |
Also I try to change the code into I still try the .txt case because I just want to ensure the type of file does not include any further problems. However, the log says that the type9e still could not read from the supplied data file. *** Fatal Error at time : 3800.000000 |
Also, try some in the type15-2 case, still not working. *** Fatal Error at time : 3000.000000 weather_xml = "./all_xml/Type15-2.xmltmf" weather_model = TrnsysModel.from_xml(weather_xml) weather_model.external_files.values = r"C:\Users\asus\Desktop\trnsys\CN-Beijing-545110.tm2" Also, I notice that the file address is not changed But your code example will raise KeyError: |
The ExternalFiles attribute is a dict-like object. Make sure you index the external file with the correct key name: import trnsystor
from trnsystor import Deck, ControlCards, TrnsysModel
from trnsystor.collections import EquationCollection
# create weather model
weather_xml = "tests/input_files/Type15-2.xml"
weather_model = TrnsysModel.from_xml(weather_xml)
# assign external file and logic number
weather_model.external_files["Which_file_contains_the_TMY_2_weather_data_"] = "tests/input_files/US-CO-Boulder-94018.tm2"
# The logical unit needs to be assigned manually
weather_model.parameters["Logical_unit"] = weather_model.external_files["Which_file_contains_the_TMY_2_weather_data_"].logical_unit
# Create online plotter
monitor_test = TrnsysModel.from_xml("tests/input_files/Type65c.xml")
monitor_test.parameters["Left_axis_minimum"] = 0
monitor_test.parameters["Left_axis_maximum"] = 30000
monitor_test.parameters["Nb_of_left_axis_variables"] = 1
# connect the two models
weather_model.connect_to(monitor_test, mapping={"Global_horizontal_radiation_not_interpolated_": "Left_axis_variable_1"})
cc = ControlCards.all()
cc.set_statement(trnsystor.statement.Simulation(start=3800, stop=4000, step=1))
deck_file = Deck(name='mytest', control_cards=cc )
list_models = [weather_model, monitor_test]
deck_file.update_models(list_models)
deck_file.save('my_project.dck') A fix [#54] regarding printing of inputs has just been pushed; That should also make sure you can run the file. See https://github.com/samuelduchesne/trnsystor/releases/tag/v1.3.7 |
It looks like the weather file reader is eating bytes out of the input file when the logical_unit number is not correct. At this point, this is an issue with TRNSYS, not trnsystor. |
But for the type9e, the logical_unit could not be set in the parameters. How to deal with this part to make sure the external file is read correctly? |
Dear author,
Thanks a lot for your work.
I just try to set the external weather file(.tm2) to type 15-2 for processing the weather data.
I could not find any detailed example in this, could you please give me an instance?
Further, I just run the type 15 in trnsystor, the tm2 file will decrease from 1232kb to 563kb. I do not know if there is any problem to damage the weather file.
Here some of the files just became 563kb
I also tested the type9e, still facing the problem of the setting of external_files, would you please give an example for how to config the external files for a model
The text was updated successfully, but these errors were encountered: