# Application of spatially varying boundary conditions and source term in AceFEM

I am trying to model a simple 2D steady state heat conduction problem using automatically generated Q2 elements.

The problem consists of a square domain with prescribed temperatures along the bottom and left edges defined by

T(x,0)=bcC*x, and

T(0,y)=bcD*y .

The flux along the right edge is defined by

q(1,y)=-2bcAy^2-bcBy+bcC

and along the top by

q(x,1)=-2bcAx^2+bcBx+bcD .

Finally, there is a source term defined by

S(x,y)=2bcA(x^2+y^2) .

So far I am having trouble applying all boundary conditions. See for example the (attempted) application of the first temperature boundary condition in the code below.

<< AceFEM;
(* Define Domain*)
BLx = 0; BLy = 0;
BRx = 1; BRy = 0;
TRx = 1; TRy = 1;
TLx = 0; TLy = 1;
(* Element Densities *)
nX = 2;
nY = 2;
(* BC magnitudes *)
bcD = 10;
bcC = 10;
bcA = 1;
bcB = 2;
(* Initialize Problem *) (* No source term yet *)
SMTInputData[];
"plate", {"ML:", "TH", "D2", "Q2", "DF", "ST", "Q2", "T",
"Fourier"}, {"kt *" -> 1., "QT *" -> 0.} ];
SMTMesh["plate",
"Q2", {2, 2}, {{{BLx, BLy}, {BRx, BRy}}, {{TLx, TLy}, {TRx, TRy}}}];
(* Apply BC *)
1 -> Function[{X, Y}, bcC/(2 nX ) (X - 1)]] ;
(* Solve *)
SMTAnalysis[];
SMTNextStep["\[Lambda]" -> 1];
While[SMTConvergence[10^-12, 10], SMTNewtonIteration[];
SMTStatusReport[];];
`

Which yields In which T ranges from 0 to 50 along the bottom instead of 0 to 10 even after scaling the function by the number of nodes.

It may be straight forward enough to scale this function further for this simple BC but how would one apply the more complex flux BCs and source term that vary spatially in a more complex way?

Any help would be appreciated!