Example #1
0
def init_chems(chem_data, r_con_data, region, region_index, u_count, v_count):

    r_concentrations = r_con_data[region_index]

    chemicals = []

    for i in range(len(chem_data)):

        concentrations = r_concentrations[i]
        chemical = chem_data[i]
        #(chemical)

        chemical = check_inst_non_st(chemical, u_count, v_count)
        concentrations = check_inst_non_st(concentrations, u_count, v_count)
        toadd = obj.Chemical(chemical[0], chemical[1], concentrations[0])

        # dealing with ddoc and dpoc
        if chemical[2] and chemical[3] != '':
            toadd.set_ddoc_dpoc(chemical[2], chemical[3])

        # dealing with betas
        noBeta = []
        for i in range(4, 13, 2):
            if chemical[i] != '' and chemical[i + 1] == '':
                toadd.set_betas(chemical[i], (i - 4) // 2)
            if chemical[i + 1] != '':
                toadd.set_koc(chemical[i + 1], (i - 4) // 2)
            if chemical[i] == '' and chemical[i + 1] == '':
                print(
                    "You are missing an entry in the chemcials tab  for a beta/*****"
                )
                exit(0)

        #print(concentrations[2])
        # dealing with cwto and cwdo
        if concentrations[1] != '':
            toadd.set_cwto(concentrations[1])
        if concentrations[2] != '':
            toadd.set_cwdo(concentrations[2])
        if concentrations[3] != '':
            toadd.set_cwp(concentrations[3])

        if toadd.Cwp != -1 and toadd.Cwdo != -1 and toadd.Cs == '' and region.Ocs != '':
            toadd.calc_cs(region)

        if toadd.Cwp != -1 and toadd.Cwdo == -1 and toadd.Cs == '' and toadd.Cwto != -1:
            toadd.calc_cs(region)

        if toadd.Cwdo == -1 and toadd.Cwto != -1 and region.adoc and region.apoc and region.Xdoc and region.Xpoc != '':
            toadd.calc_phi_and_cwdo(region)

        if toadd.Cwdo == -1 and (toadd.Cwto == -1 or region.adoc or region.apoc
                                 or region.Xdoc or region.Xpoc == ''):
            print(
                'Not enough parameters to solve for Cwdo in ' + chemical[0],
                '\nRefer to page 13 section 3.7 and page 15 section 3.10 of the user manual for help.'
            )
            exit(0)

        if toadd.Cwp == -1 and region.Ocs != '':
            toadd.calc_pore_water(region.Ocs)
        if toadd.Cwp == -1 and (region.Ocs == '' or toadd.Cs == ''):
            print(
                'Not enough parameters to solve for Cwp in' + chemical[0],
                '\nRefer to page 13 section 3.7 and page 15 section 3.10 of the user manual for help.'
            )
            exit(0)

        chemicals.append(toadd)

    return chemicals