def test_define_material(): from solcore import ParameterSystem, MaterialSystem this_dir = os.path.split(__file__)[0] create_new_material( "SiGeSn", os.path.join(this_dir, "data", "SiGeSn_n.txt"), os.path.join(this_dir, "data", "SiGeSn_k.txt"), os.path.join(this_dir, "data", "SiGeSn_params.txt"), ) assert "SiGeSn" in ParameterSystem().database.sections() assert "SiGeSn".lower() in MaterialSystem().sources SiGeSn = material("SiGeSn")() assert SiGeSn.n(400e-9) == approx(4.175308391752484) assert SiGeSn.k(400e-9) == approx(2.3037424963866306)
When adding custom materials - or getting the refractive index database - the information will be stored in the Solcore's users folder. These can be setup by setting the SOLCORE_USER_DATA environmental variable to your prefered location or, by default, it will be in your home directory, in a directory called .solcore. """ """ EXAMPLE 1 need to have n and k data, and a parameter file in the correct format - see examples of parameter files in e.g. material_data/Adachi/binaries.txt create a new material, silicon-germanium-tin, from input files. Here, the parameters in SiGeSn_params.txt have been copied directly from Ge. """ create_new_material('SiGeSn', 'data/SiGeSn_n.txt', 'data/SiGeSn_k.txt', 'data/SiGeSn_params.txt') # can now create an instance of it like any Solcore material SiGeSn = material('SiGeSn')() plt.figure() plt.plot( si(np.arange(300, 1700, 5), 'nm') * 1e9, SiGeSn.n(si(np.arange(300, 1700, 5), 'nm'))) plt.plot( si(np.arange(300, 1700, 5), 'nm') * 1e9, SiGeSn.k(si(np.arange(300, 1700, 5), 'nm'))) plt.xlabel('Wavelength (nm)') plt.ylabel('SiGeSn n / k')
# First, using a purely optical TMM simulation to calculate the photogenerated current in each sub-cell. The thing to # optimize is then the current of the current-limiting cell in the structure; in other words we want to *maximize* the # lowest sub-cell current, to achieve current-matching with the highest possible current. # Since differential evolution does a minimization, we are actually minimizing the negative of # this value. # Once we have good initial values for the total layer thicknesses, use full electrical simulations to determine the # n and p type layer thicknesses to calculate a maximum possible efficiency for the 4J device. # To use yabox/the optimization module for the DE, we need to define a class which sets up the problem and has an 'evaluate' function, which # will actually calculate the value we are trying to minimize for a set of parameters. # add SiGeSn optical constants to the database create_new_material( 'SiGeSn', 'SiGeSn_n.txt', 'SiGeSn_k.txt', 'SiGeSn_params.txt') # Note: comment out this line after the material # has been added to avoid being asked if you want to overwrite it. # define class for the optimization: class calc_min_Jsc(): def __init__(self): # initialize an instance of the class; set some information which will be used in each iteration of the calculation: # materials, wavelengths, the light source T = 298 wl = np.linspace(300, 1900, 800) # materials
information will be stored in the Solcore's users folder. These can be setup by setting the SOLCORE_USER_DATA environmental variable to your prefered location or, by default, it will be in your home directory, in a directory called .solcore. """ """ EXAMPLE 1 need to have n and k data, and a parameter file in the correct format - see examples of parameter files in e.g. material_data/Adachi/binaries.txt create a new material, silicon-germanium-tin, from input files. Here, the parameters in SiGeSn_params.txt have been copied directly from Ge. """ create_new_material('SiGeSn', 'data/SiGeSn_n.txt', 'data/SiGeSn_k.txt', 'data/SiGeSn_params.txt') # Note that the final argument, the parameter file, is optional - if you do not # provide it, a material will be added with optical constants only, so it can be # used for optical calculations. # can now create an instance of it like any Solcore material SiGeSn = material('SiGeSn')() plt.figure() plt.plot(si(np.arange(300, 1700, 5), 'nm')*1e9, SiGeSn.n(si(np.arange(300, 1700, 5), 'nm'))) plt.plot(si(np.arange(300, 1700, 5), 'nm')*1e9, SiGeSn.k(si(np.arange(300, 1700, 5), 'nm'))) plt.xlabel('Wavelength (nm)') plt.ylabel('SiGeSn n / k')
# To set up the use of custom materials, first we need to tell Solcore some things about where to put custom materials. for this, # we use the add_source function from config_tools, although we could also manually edit # the solcore configuration file (which should be in your home directory). # You need to add two things to the config file: where to put the n and k data for new # materials added to the database, and where to put the other parameters (these can all # go in the same file). home_folder = os.path.expanduser('~') custom_nk_path = os.path.join(home_folder, 'Solcore/custommats') nk_db_path = os.path.join(home_folder, 'Solcore/NK.db') param_path = os.path.join(home_folder, 'Solcore/custom_params.txt') add_source('Others', 'custom_mats', custom_nk_path) add_source('Others', 'nk', nk_db_path) add_source('Parameters', 'custom', param_path) import pandas as pd names = ['GaAs_subs', 'InAlP', 'InGaP', 'SiGeSn_29111'] for name in names[:3]: data = pd.read_csv('data/'+name+'.txt', sep='\t', names=['wl', 'n', 'k']) data['wl'] = data['wl']*1e-9 np.savetxt('data/'+name+'_n.txt', data[['wl', 'n']]) np.savetxt('data/'+name+'_k.txt', data[['wl', 'k']]) sol_names = ['GaAs_WVASE', 'InAlP_WVASE', 'InGaP_WVASE', 'SiGeSn'] for i1, name in enumerate(sol_names): create_new_material(name, 'data/'+names[i1]+'_n.txt', 'data/'+names[i1]+'_k.txt')