# Pinning at the borders def pinning(p): x = float(SI(p[0], "m")/(hl*unit_length)) if abs(x) >= 0.999: return 0.0 else: return 1.0 mat_Py = MagMaterial('Py', Ms=SI(0.86e6, 'A/m'), exchange_coupling=SI(13e-12, 'J/m')) s = Simulation() s.load_mesh(run.get_mesh_file_name(), [('region1', mat_Py)], unit_length=unit_length) s.set_m(m0) s.set_pinning(pinning) s.relax(save=[('fields', at('time', SI(0, 's')) | at('convergence'))]) s.set_m(m1) s.relax(save=[('fields', at('stage_time', SI(0, 's')) | at('convergence'))])