def main(): from sfepy.base.base import output from sfepy.base.conf import ProblemConf, get_standard_keywords from sfepy.fem import ProblemDefinition from sfepy.applications import solve_evolutionary output.prefix = 'therel:' required, other = get_standard_keywords() conf = ProblemConf.from_file(__file__, required, other) problem = ProblemDefinition.from_conf(conf, init_equations=False) # Setup output directory according to options above. problem.setup_default_output() # First solve the stationary electric conduction problem. problem.set_equations({'eq' : conf.equations['1']}) problem.time_update() state_el = problem.solve() problem.save_state(problem.get_output_name(suffix = 'el'), state_el) # Then solve the evolutionary heat conduction problem, using state_el. problem.set_equations({'eq' : conf.equations['2']}) phi_var = problem.get_variables()['phi_known'] phi_var.data_from_any(state_el()) solve_evolutionary(problem) output('results saved in %s' % problem.get_output_name(suffix = '*'))
def solve_branch(problem, branch_function): from sfepy.applications import solve_evolutionary displacements = {} for key, eq in problem.conf.equations.iteritems(): problem.set_equations( {key : eq} ) load = problem.get_materials()['load'] load.set_function(branch_function) out = [] solve_evolutionary(problem, save_results=False, step_hook=store_top_u(out)) displacements[key] = nm.array( out, dtype = nm.float64 ) return displacements
def solve_branch(problem, branch_function): from sfepy.applications import solve_evolutionary displacements = {} for key, eq in problem.conf.equations.iteritems(): problem.set_equations({key: eq}) load = problem.get_materials()['load'] load.set_function(branch_function) out = [] solve_evolutionary(problem, save_results=False, step_hook=store_top_u(out)) displacements[key] = nm.array(out, dtype=nm.float64) return displacements