function HeatConduction1(varargin)
disp('Model heat conduction in one dimension')
nx = 100; % number of instances along x
length = 100.0; % m
deltax = length / nx;
deltay = 1.0; 
deltaz = 1.0; % m
porosity = 0.25; % volume fraction

tcond = 2.0; % W/m/K
trans = deltay * deltaz * tcond / deltax;

time_end = 15.0;
delta_years = time_end / 3.0;
next_output = 0.0;

% Open output file and write instance positions on the first line
fileID = fopen('HeatConduction.txt', 'w');
fprintf(fileID, 'years');
for i = 0:(nx-1)
    fprintf(fileID, '\t%3.6f', (i+0.5)* deltax);
end
fprintf(fileID, '\n');

% Configure and initialize the  instances
cp = cell(nx,1);
for i = 1:nx
    cp{i} = ChemPlugin();
end
Console(cp{1}, 'HeatConduction_stdout.txt');
Config(cp{1}, 'pluses = banner');

cmd = 'span 20 C to 100 C; Na+ = 0.001 mmol/kg; Cl- = 0.001 mmol/kg;';
cmd = strcat(cmd, 'volume = ', num2str(deltax * deltay * deltaz),' m3;', ...
    'porosity = ', num2str(porosity), ';', ...
    'time end = ', num2str(time_end), ' year;');

for i = 1:nx
    Config(cp{i}, cmd);
    
    if i < nx/2 + 1
        Config(cp{i}, 'T = 100 C');
    else
        Config(cp{i}, 'T = 20 C');
    end
        
    if Initialize(cp{i})
        error('Instance %i failed to initialize', i);
    end
end
report_value = 'temperature'; units = 'C';
next_output = write_line(fileID, cp, nx, delta_years,...
    next_output, report_value, units);

for i = 2:nx
    link1 = Link(cp{i}, cp{i-1});
    HeatTrans(link1, trans, 'W/K');
end

NotDone = 1;
while NotDone
    deltat = 1e99;
    for i = 1:nx
        deltat = min(deltat, ReportTimeStep(cp{i}));
    end
    for i = 1:nx
       if (AdvanceTimeStep(cp{i}, deltat))
           NotDone = 0;
       end
    end
    for i = 1:nx
        if (AdvanceHeatTransport(cp{i}))
            error('Advance Heat Transport failed for instance %i',i);
        end
    end
    for i = 1:nx
        if (AdvanceChemical(cp{i}))
            error('Advance Transport failed for instance %i',i);
        end
    end
    next_output = write_line(fileID, cp, nx, delta_years,...
    next_output, report_value, units);
end
fclose(fileID);
end
