I would like to prescribe a boundary condition for an initial time duration and then remove it for the remaining time duration. Commercial finite element solvers allow you to do this by specifying steps. I tried to implement it using the code below. This is
 giving nonsensical results at and after the time at which the BCs change. Can you please assist me in how I may implement this properly. I can share the full code if needed.
m = rho*inner((u - 2.0 * u_n + u_nm1),v) / Constant(dt * dt) * dxlump
k= inner(sigma(u_n),epsilon(v))*dx
def collar_load(t,T,freq,amp=1.0):
    return amp*hanning(t,T)*stepfn(t,T)*np.sin(freq*t)
# Define the loading as an expression depending on t
t=0
collar_disp= Constant([0.0, 0.0, 0.0])
F = m+k
a, r = lhs(F), rhs(F)
zero = Constant((0.0, 0.0, 0.0))
# Dirichlet BC that is valid for the entire time duration
bc1 = DirichletBC(V, zero, 11)
# Collar BC that remains on till T_pulse
bc2= DirichletBC(V, collar_disp, 21)
# My attempt of defining two problems to mimic two simulation steps
problem1 = LinearVariationalProblem(a, r, u_np1, bcs=[bc1,bc2], constant_jacobian=True)
solver1 = LinearVariationalSolver(problem1, solver_parameters=params)
problem2 = LinearVariationalProblem(a, r, u_np1, bcs=[bc1], constant_jacobian=True)
solver2 = LinearVariationalSolver(problem2, solver_parameters=params)
for i in range(len(time)):
    t = time[i]
    if (t<=T_pulse):
        solver1.solve()
    else:
        solver2.solve()