def save_solution_test(): problem = agros2d.problem() field = agros2d.field('magnetic') problem.solve() values_from_solution = [field.local_values(0.05, 0), field.surface_integrals([0, 1, 2]), field.volume_integrals()] from os import path filename = '{0}/temp.a2d'.format(path.dirname(pythonlab.tempname())) agros2d.save_file(filename, True) agros2d.open_file(filename, True) field = agros2d.field('magnetic') values_from_file = [field.local_values(0.05, 0), field.surface_integrals([0, 1, 2]), field.volume_integrals()] return compare(values_from_solution, values_from_file)
def save_solution_test(): problem = agros2d.problem() field = agros2d.field('magnetic') problem.solve() values_from_solution = [ field.local_values(0.05, 0), field.surface_integrals([0, 1, 2]), field.volume_integrals() ] from os import path filename = '{0}/temp.a2d'.format(path.dirname(pythonlab.tempname())) agros2d.save_file(filename, True) agros2d.open_file(filename, True) field = agros2d.field('magnetic') values_from_file = [ field.local_values(0.05, 0), field.surface_integrals([0, 1, 2]), field.volume_integrals() ] return compare(values_from_solution, values_from_file)
def test(self): agros2d.open_file(example) agros2d.problem().solve()
import agros2d import pythonlab from math import pi agros2d.open_file( pythonlab.datadir( 'resources/examples/Examples/Magnetic Field/Magnetostatics/Switched Reluctance Machine.a2d' )) def get_energy(dphi, Jext): problem = agros2d.problem() magnetic = agros2d.field("magnetic") for coil in Jext: magnetic.modify_material( "Copper {0}+".format(coil), {"magnetic_current_density_external_real": +Jext[coil]}) magnetic.modify_material( "Copper {0}-".format(coil), {"magnetic_current_density_external_real": -Jext[coil]}) geometry = agros2d.geometry geometry.select_edges(range(64, 80)) geometry.rotate_selection(0, 0, dphi) problem.solve() return magnetic.volume_integrals()['Wm'] def get_density(phi):
import agros2d import pythonlab from math import pi agros2d.open_file('Switched Reluctance Machine.a2d') def get_energy(dphi, Jext): problem = agros2d.problem() magnetic = agros2d.field("magnetic") for coil in Jext: magnetic.modify_material("Copper {0}+".format(coil), {"magnetic_current_density_external_real" : +Jext[coil]}) magnetic.modify_material("Copper {0}-".format(coil), {"magnetic_current_density_external_real" : -Jext[coil]}) geometry = agros2d.geometry geometry.select_edges(range(64, 80)) geometry.rotate_selection(0, 0, dphi) problem.solve() return magnetic.volume_integrals()['Wm'] def get_density(phi): Jext = {'A' : 0.0, 'B' : 0.0, 'C' : 0.0} J_EXT = 2e6 if ((phi >= 60 and phi < 90) or (phi >= 150 and phi < 180)): Jext['A'] = J_EXT if ((phi >= 0 and phi < 30) or (phi >= 90 and phi < 120) or
def test(self): agros2d.open_file(example) script = agros2d.get_script_from_model() exec script in globals(), locals() agros2d.problem().solve()
import agros2d import pythonlab from math import pi agros2d.open_file(pythonlab.datadir('resources/examples/Examples/Magnetic Field/Magnetostatics/Switched Reluctance Machine.a2d')) def get_energy(dphi, Jext): problem = agros2d.problem() magnetic = agros2d.field("magnetic") for coil in Jext: magnetic.modify_material("Copper {0}+".format(coil), {"magnetic_current_density_external_real" : +Jext[coil]}) magnetic.modify_material("Copper {0}-".format(coil), {"magnetic_current_density_external_real" : -Jext[coil]}) geometry = agros2d.geometry geometry.select_edges(range(64, 80)) geometry.rotate_selection(0, 0, dphi) problem.solve() return magnetic.volume_integrals()['Wm'] def get_density(phi): Jext = {'A' : 0.0, 'B' : 0.0, 'C' : 0.0} J_EXT = 2e6 if ((phi >= 60 and phi < 90) or (phi >= 150 and phi < 180)): Jext['A'] = J_EXT if ((phi >= 0 and phi < 30) or (phi >= 90 and phi < 120) or