LBNL-ETA / pyWinCalc

Other
19 stars 10 forks source link

Problems with custom glazing, but using optics file spectral data. #30

Closed aegis1980 closed 1 year ago

aegis1980 commented 2 years ago

If I run a modified version of examples/custom_glazing_single_layer.py but importing measured wavelength data from CLEAR_6.DAT (rather than using dictionary values in example), I get an incorrect set of results (U value and SHGC at least). U = 7.0 and SHGC = 0.799.

Values ought to be U = 5.818 and SHGC =0.818 (which I get running examples/single_clear.py with CLEAR_6.DAT, or in WINDOW7.7)

What am I doing wrong? I get same issue whatever the optics file I use.

My modified version of examples/custom_glazing_single_layer.py to read in spectral data from optics file:

def spectral_from_optics_file(filename):
    in_data = False
    pywincalc_wavelength_measured_data = []
    with open(filename) as file:
        while (line := file.readline().rstrip()):
            if "Structure" in line:
                in_data = True
                continue
            if in_data:
                points = line. Split('    ')
                pywincalc_wavelength_measured_data.append(
                    pywincalc.WavelengthData(
                        float(points[0]), #wavelength_microns:
                        float(points[1]), #direct_transmittance
                        float(points[2]),#direct_reflectance_front:
                        float(points[3]) #direct_reflectance_back:
                     ))

    return pywincalc_wavelength_measured_data

optical_standard_path = os.path.join(PATH_STANDARDS,"W5_NFRC_2003.std")
optical_standard = pywincalc.load_standard(optical_standard_path)

glazing_system_width = 1.0  # width of the glazing system in meters
glazing_system_height = 1.0  # height of the glazing system in meters

# Create optical data for the glass layer

# Make sure to select the approriate material type for the layer.
# Current supported options are: 
# APPLIED_FILM, COATED, ELECTROCHROMIC, FILM, INTERLAYER, LAMINATE, MONOLITHIC, THERMOCHROMIC
glass_material_type = pywincalc.MaterialType.MONOLITHIC
glass_material_thickness = 5.715 /1000  

glass_wavelength_measurements = spectral_from_optics_file(os.path.join(PATH_PRODUCTS,'CLEAR_6.DAT'))

# Since the measurements do not extend to the IR range emissivity and IR transmittances should be provided
# If there are measurements that extend to the IR range these values can be provided but result calculated
# from the measurements will be used
glass_emissivity_front = .84
glass_emissivity_back = .84
glass_ir_transmittance_front = 0
glass_ir_transmittance_back = 0
glass_coated_side = pywincalc.CoatedSide.NEITHER
flipped = False

glass_n_band_optical_data = pywincalc.ProductDataOpticalNBand(glass_material_type,
                                                              glass_material_thickness,
                                                              glass_wavelength_measurements,
                                                              glass_coated_side,
                                                              glass_emissivity_front,
                                                              glass_emissivity_back,
                                                              glass_ir_transmittance_front,
                                                              glass_ir_transmittance_back,
                                                              flipped)

# Next create the thermal data for the glass layer
glass_conductivity = 1
# Since thermal openings in this case are all zero they can be omitted.  They are included he for example purposes.
glass_opening_top = 0
glass_opening_bottom = 0
glass_opening_left = 0
glass_opening_right = 0

glass_thermal = pywincalc.ProductDataThermal(glass_conductivity,glass_material_thickness)

# Create a glass layer from both the optical and thermal data
glass_layer = pywincalc.ProductDataOpticalAndThermal(glass_n_band_optical_data, glass_thermal)

# Create a glazing system using the NFRC U environment in order to get NFRC U results
# U and SHGC can be caculated for any given environment but in order to get results
# The NFRC U and SHGC environments are provided as already constructed environments and Glazing_System
# defaults to using the NFRC U environments
glazing_system_u_environment = pywincalc.GlazingSystem(optical_standard=optical_standard,
                                                       solid_layers=[glass_layer],
                                                       width_meters=glazing_system_width,
                                                       height_meters=glazing_system_height)

# In order to get NFRC SHGC results the NFRC SHGC environment should be used when creating the glazing system
glazing_system_shgc_environment = pywincalc.GlazingSystem(optical_standard=optical_standard,
                                                          solid_layers=[glass_layer],
                                                          width_meters=glazing_system_width,
                                                          height_meters=glazing_system_height,
                                                          environment=pywincalc.nfrc_shgc_environments())

results_name = "Results for a single-layer system with a single glazing layer made from user-defined spectral data."
print("*" * len(results_name))
print(results_name)
print("*" * len(results_name))
results_printer.print_results(glazing_system_u_environment, glazing_system_shgc_environment)
StephenCzarnecki commented 1 year ago

Sorry for the delayed response.  September is the "end of the year" here and as such a very busy time.

Also mea culpa.  I believe the only thing you did wrong was follow an example that had positional arguments in the wrong order when calling pywincalc.ProductDataOpticalNBand. 

I have updated the custom_glazing_single_layer.py and custom_perforated.py examples to correct the order and also pass the parameters by keyword. 

E.g. the call to pywincalc.ProductDataOpticalNBand in custom_glazing_single_layer.py now looks like

glass_n_band_optical_data = pywincalc.ProductDataOpticalNBand(material_type=glass_material_type,
                                                              thickness_meters=glass_material_thickness,
                                                              wavelength_data=glass_wavelength_measurements,
                                                              coated_side=glass_coated_side,
                                                              ir_transmittance_front=glass_ir_transmittance_front,
                                                              ir_transmittance_back=glass_ir_transmittance_back,
                                                              emissivity_front=glass_emissivity_front,
                                                              emissivity_back=glass_emissivity_back,
                                                              permeability_factor=glass_permeability_factor,
                                                              flipped=flipped)

Now if I run single_clear.py and custom_glazing_single_layer.py the same data but in different forms both give the same U-value of 5.91251455879485.

Hopefully this resolves things for you.  If not, or if you notice anything else, please let us know.

Thanks

aegis1980 commented 1 year ago

Perfect. I will give it a go. I had work around whereby I wrote optics tempfile and using parse_optics_file. Works fine but doing it the proper wall will be much more succinct.