% To find the equilibrium state, we simply assign a fixed pressure BC to
% the 100 topmost faces, and simulate for 50 years with looong timesteps
f = boundaryFaces(G);
[~, ix] = sort((G.faces.centroids(f,3)));
nf = 1;
bc = addBC([], f(ix(1:nf)), 'pressure', p0, 'sat', 1);
bc = addThermalBCProps(bc, 'T', T0(G.faces.centroids(f(ix(1:nf)),:)));
bc.x = ones(numel(bc.face),1);
figure(2);
plotGrid(G)
plotFaces(G, bc.face, 'FaceColor', 'red');
%alpha(0.2);% make grid slightly transparent
axis equal tight;
view(3);
title('Boundary-condition faces');
% Make schedule
dtPre = rampupTimesteps(50*year, 10*year, 3);
schedulePre = simpleSchedule(dtPre, 'bc', bc);
[~, statesPre, ~] = simulateScheduleAD(state0, model, schedulePre, ...
'linearSolver', lsolver);
state0 = statesPre{end}; % Set initial state
state0 = rmfield(state0, 'wellSol');