'Sub relay_control() 'It is presumed that QuickField is already started, the problem coil.pbm is opened. 'The plunger is placed in x=0 position 'LabelMover file relay.qva is opened if (MsgBox("1. Start QuickField and open coil_problem.pbm" & chr(13) & "2. Open relay_control.qva in LabelMover." & chr(13) & "3. Press OK button.",1) <> 1 ) then WScript.Quit() end if 'relay parameters Dim x_out ' As Double Dim x_in ' As Double Dim m_mass ' As Double Dim k ' As Double Dim x_spring_free ' As Double x_out = 0.01 ' pull out position. m x_in = 0.006 ' pull in position, m m_mass = 0.0045 ' plunger weight, kg k = 4.0 ' spring constant, N/m x_spring_free = 0.015 ' spring free would be position, m 'initial conditions Dim t_time ' As Double Dim x_position ' As Double Dim v_speed ' As Double t_time = 0.0 ' time, s x_position = x_out ' plunger position, m v_speed = 0.0 ' plunger speed, m/s 'integration time step, s Dim dt_time_step ' As Double dt_time_step = 0.005 Dim theForce ' As Double Dim max_time ' As Double max_time = 0.2 ' maximal integration time While (t_time < max_time) And (x_position > x_in) ' electromagnetic force theForce = getQfForceX(x_position) ' add spring force theForce = theForce + (x_spring_free - x_position) * k ' calculate acceleration and speed v_speed = v_speed + theForce / m_mass * dt_time_step ' calculate plunger position x_position = x_position + v_speed * dt_time_step t_time = t_time + dt_time_step '''''''''''''' 'output results are stored in LabelMover '''''''''''''' Wend 'End Sub Function getQfForceX(x_position) 'calculate force in QuickField 'It is presumed that QuickField is already started, the problem is opened. 'The plunger is placed in x=0 position 'LabelMover file relay.qva is opened ' 0. hook LabelMover (QuickField tool) ' 1. specify plunger position ' 2. get the force Dim qlm ' As qlm.SimpleInterface Set qlm = CreateObject("qlm.SimpleInterface") ' 1. specify plunger position Call qlm.SetVariation (0, x_position) ' 2. get the force Call qlm.Solve getQfForceX = qlm.GetResult(0) ' each step is stored in LabelMover End Function