# AceFEM: Can I change boundary conditions in the middle of analysis session?

I'd like to compute an example of a clamped column that is subjected to mixed types of load. Namely, the load consists of the horizontal force λF0 and the vertical prescribed displacement v0 that remains constant throughout the analysis. I will use finite element with nonlinear constitutive law, therefore I have to perform analysis in two phases: (1) preliminary analysis with prescribed displacement v0 only (without horizontal force F0) and (2) main analysis of the example with variable force F0.

Once the preliminary analysis is computed, the prescribed displacement v0 become constant and the horizontal force F0 is applied subsequently. How to do this in AceFEM?

In AceFEM, the (Dirichlet or Neumann) boundary conditions can be applied by using commands SMTAddEssentialBoundary[] and SMTAddNaturalBoundary[]. Those commands are normally used in the input data phase, before an analysis starts. However, the same commands can be called in the middle of analysis to change the boundary conditions with the option "set"->True.

In the user help for AceFEM, you can find an example:

SMTAddEssentialBoundary[Line[{{0, 0}, {1, 1}}, "D"], 3 -> 1.5, "Set" -> True]


Here is a simple code for the two-phase analysis of an example from the question:

<< AceFEM;
SMTInputData[];
L = 2; H = 10;
SMTAddMesh[Polygon[{{0, 0}, {L, 0}, {L, H}, {0, H}}], "A",
"Q1", {4, 20}];

v0 = -0.01;  (* Reference value of the prescribed vertical displacement *)
F0 = 1;      (* Reference value of the horizontal force *)

SMTAddEssentialBoundary["Y" == 0 &, 1 -> 0, 2 -> 0];
SMTAddEssentialBoundary["Y" == H &, 2 -> v0];   (* Prescribed displacement is a variable load in the preliminary phase*)

SMTAnalysis[];

AnalysisBlock[FinalMultiplier_] := Block[{},
While[
While[
step = SMTConvergence[10^-8,15, {"Adaptive BC", 8, 10^-4, 0.1, FinalMultiplier}],
SMTNewtonIteration[];];
If[Not[step[[1]]],
AppendTo[res, {SMTNodeData[nodeDispl, "at"],SMTRData["Multiplier"]}];
];
If[step[[4]] === "MinBound", SMTStatusReport["Analyze"];SMTStepBack[]];
step[[3]]
,
If[step[[1]], SMTStepBack[];];
SMTNextStep[1, step[[2]]]
];
];

res = {};
nodeDispl = SMTFindNodes[Point[{L, H}]][[1]];

(* PRELIMINARY ANALYSIS *)
(* Compute preliminary analysis, where multiplier goes from 0 to 1,
to get correct state of model for prescribed displacement v0 *)

SMTNextStep[1,0.1];
AnalysisBlock[1]

(* CHANGE BOUNDARY CONDITIONS *)

(* Variable prescribed vertical displacements v0 becomes constant vertical displacement *)
SMTAddEssentialBoundary["Y" == H &, 2 -> 0, "Set" -> True];

(* Apply horizontal force F0=1 *)
SMTAddNaturalBoundary["X" == 0 && "Y" == H &, 1 -> F0,"Set" -> True];

(* Continue with THE PRIMARY ANALYSIS *)

SMTNextStep[1,0.01];
AnalysisBlock[2]
`