Skip to content

Expose rtol and atol for is_it_time_to_export #1074

@RemDelaporteMathurin

Description

@RemDelaporteMathurin

For very large simulations, even with a rtol=1e-5 the export will be exported very far from the desired export time.

Consider the following:

import numpy as np

import festim as F

model = F.HydrogenTransportProblem()
model.mesh = F.Mesh1D(np.linspace(0, 1, 10))

mat = F.Material(D_0=1.0, E_D=0.0)
vol = F.VolumeSubdomain1D(id=1, material=mat, borders=[0, 1])

model.subdomains = [vol]

H = F.Species("H")
model.species = [H]

model.temperature = 300

model.settings = F.Settings(atol=1e-12, rtol=1e-12, final_time=0.9e8 + 20)
model.settings.stepsize = F.Stepsize(1, milestones=[0.9e8])


model.exports = [
    F.Profile1DExport(H, subdomain=vol, times=[0.9e8]),
]

model.initialise()
model.t.value = 0.9e8 - 10

model.run()

assert abs(model.exports[0].t[0] - 0.9e8) < 1e-12, (
    "time of export is far from the expected"
)

proposed solution

expose rtol and atol in is_it_time_to_export as an argument of F.Settings that will be used for all exports

Tagging @AdriaLlealS

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions