![]() ![]() I could just use the dictionary returned from the YAML package but I find it easier and cleaner to get the parameter values with a class interface. This approach works fine but when more parameters are added to the YAML file it requires additional code to be added to the class objects. Self.gas_mass_flow = float(rdict.split()) Self.diameter_inner = float(rdict.split()) Below is an example of how I envision using the approach for a much larger project: ![]() The class attributers are then used to obtain the values associated with the parameters. To allow easier access to the nested parameters, I use an intermediate Python class to parse the dictionary values into class attributes. I'm using the PyYAML package to read the YAML file into a Python dictionary. Units are important for the calculations so the YAML file needs to convey that information too. For example, parameters used by the reactor model are listed in the reactor section. Parameters for the Python model are organized based on the type of computations they apply to. Sphericity: 0.65 unitless # assumed valueĭiameters:, microns] # sieve screen diameters Thermal_conductivity: 1.4 W/mK # based on value for pine (2) Sphericity: 0.89 unitless # assumed value An example of such a file is below:ĭiameter: 2.5 mm # mean Sauter diameter (1) I would like to use a YAML file to store parameters used by computational models developed in Python. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |