# Outputting data at t = 0

**URL:** <https://festim.discourse.group/t/outputting-data-at-t-0/91>\
**Category:** User Support\
**Created:** [December 17, 2024, 4:55pm UTC](https://festim.discourse.group/t/outputting-data-at-t-0/91 "2024-12-17T16:55:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![HelenS](https://avatars.discourse-cdn.com/v4/letter/h/90ced4/32.png) [@HelenS](https://festim.discourse.group/u/HelenS)\
**Post date:** [December 17, 2024, 4:55pm UTC](https://festim.discourse.group/t/outputting-data-at-t-0/91/1 "2024-12-17T16:55:48Z")

</div>

How do I output results at time zero, please? adding 0 to this line does not seem to work:  
F.TXTExport(  
field=“solute”,  
times=[0,1,2,3,1000],  
filename=results\_folder + “/mobile\_concentration.txt”,

---

<div class="post-metadata">

**Author:** ![remidm](https://yyz2.discourse-cdn.com/free1/user_avatar/festim.discourse.group/remidm/32/4_2.png) [@remidm](https://festim.discourse.group/u/remidm)\
**Post date:** [December 17, 2024, 6:09pm UTC](https://festim.discourse.group/t/outputting-data-at-t-0/91/2 "2024-12-17T18:09:33Z")

</div>

Hi @HelenS ,

💡 Quick tip: you can format your code using three ` signs like this

```python
F.TXTExport(
    field=“solute”,
    times=[0,1,2,3,1000],
    filename=results_folder + “/mobile_concentration.txt”,
)

```

It makes it easier for us to read your code 🙂

It is not possible to export the field at time 0 at the moment.

---

<div class="post-metadata">

**Author:** ![remidm](https://yyz2.discourse-cdn.com/free1/user_avatar/festim.discourse.group/remidm/32/4_2.png) [@remidm](https://festim.discourse.group/u/remidm)\
**Post date:** [December 18, 2024, 2:21pm UTC](https://festim.discourse.group/t/outputting-data-at-t-0/91/3 "2024-12-18T14:21:15Z")

</div>

Hi Helen,

I have been giving this some thoughts and this is how you can hack your way to export everything at t=0s.

In this example (adapted from task 1 of the workshop), there is an initial condition of c=1e21 H/m3 everywhere in the 1D domain.

The concentration on the surfaces is set to zero.

```python
import numpy as np

import festim as F

my_model = F.Simulation()

my_model.mesh = F.MeshFromVertices(vertices=np.linspace(0, 7e-6, num=1001))

my_model.materials = F.Material(id=1, D_0=1e-7, E_D=0.2)

my_model.T = 300

my_model.boundary_conditions = [
    F.DirichletBC(surfaces=[1, 2], value=0, field=0) # H/m3/s
]

my_model.initial_conditions = [F.InitialCondition(field=0, value=1e21)]

my_model.settings = F.Settings(
    absolute_tolerance=1e10, relative_tolerance=1e-10, final_time=2 # s
)
results_folder = "results"

xdmf_export = F.XDMFExport(
    field="solute",
    filename=results_folder + "/hydrogen_concentration.xdmf",
    checkpoint=False, # needed in 1D
)
txt_export = F.TXTExport(
    field="solute",
    times=[0.0, 0.1, 0.2, 0.5, 1],
    filename=results_folder + "/mobile_concentration.txt",
)
my_model.exports = [xdmf_export, txt_export]
my_model.dt = F.Stepsize(0.05, milestones=[0.1, 0.2, 0.5, 1]) # s
my_model.initialise()

# little hack to export for t=0s after calling .initialise()

my_model.exports.final_time = my_model.settings.final_time
my_model.h_transport_problem.u.assign(my_model.h_transport_problem.u_n)
my_model.run_post_processing()

# run the simulation
my_model.run()

# plot solution

import matplotlib.pyplot as plt
import numpy as np

data = np.genfromtxt(
    results_folder + "/mobile_concentration.txt", skip_header=1, delimiter=","
)

for i, t in enumerate(txt_export.times):
    plt.plot(data[:, 0], data[:, i + 1], label=f"t={t:.1f}s")

plt.xlabel("x (m)")
plt.ylabel("Mobile concentration (H/m3)")
plt.legend()
plt.show()

```

This produces the following plot:

 ![image](https://global.discourse-cdn.com/free1/uploads/festim/original/1X/b3e73fc8a50e5cd77d1eb16942ac880b9b216771.png)
