self.linear_solver = om.DirectSolver() if __name__ == "__main__": # test script for trivial optimization to maximize battery temperature from Conductors import parse_cond from ViewFactors import parse_vf from inits import inits # define boundary conditions nodals = 'Nodal_data.csv' conductors = 'Cond_data.csv' n, GL_init, GR_init, QI_init, QS_init = inits(nodals, conductors) user_conductors = 'conductors.txt' cond_data = parse_cond(user_conductors) cond_nodes = {} shape_factors = {} k = {} for entry in cond_data: cond_nodes.update( {entry['cond_name'] : entry['nodes']} ) shape_factors.update( {entry['cond_name'] : entry['SF'] } ) k.update( {entry['cond_name'] : entry['conductivity'] } ) view_factors = 'viewfactors.txt' vf_data = parse_vf(view_factors) vf_nodes = [] area = []
params.add_output('beta', val=np.zeros(npts) ) params.add_output('dist', val=[1., 3.]) model = Solar(npts=npts, area=area) model.add_subsystem('params', params, promotes=['*']) problem = om.Problem(model=model) problem.setup(check=True) problem.run_model() #check_partials_data = problem.check_partials(compact_print=True, show_only_incorrect=False, form='central', step=1e-02) #compare results with esatan nodes = 'Nodal_data.csv' conductors = 'Cond_data.csv' n, GL_init1, GR_init1, QI_init1, QS_init1 = inits(nodes, conductors) nodes2 = 'Nodal_data_2.csv' conductors2 = 'Cond_data_2.csv' n, GL_init2, GR_init2, QI_init2, QS_init2 = inits(nodes2, conductors2) npts = 2 QS_init = np.concatenate((QS_init2, QS_init1), axis=1) print((problem['QS_c'] - QS_init[1:12,:]*0.91/0.61)/problem['QS_c']) #print(QS_init[1:12,:]*0.91/0.61) #problem.model.list_inputs(print_arrays=True)