It is possible to change the material in a step function with something
like this:

import meep as mp

def change_mat(sim):
    t = sim.meep_time()
    fn = t * 0.2
    geom = [mp.Sphere(radius=0.025, center=mp.Vector3(fn))]

sim = mp.Simulation(
    cell_size=mp.Vector3(10, 10),
), mp.at_time(10, change_mat),
             mp.at_end(mp.output_epsilon), until=60)

However, it is currently not possible to change the susceptibilities.

The `set_materials_from_geometry` call is a bit ponderous, so I'm planning
to add a public `Simulation.set_materials` method that only requires
geometry and/or default_material.  In the current state, this will be very
slow, but issue #207 ( will
speed it up when it's implemented.

Also note that the current master will segfault after successfully
completing `` in the above script. This will be fixed once PR#209 ( is merged.


On Thu, Feb 15, 2018 at 8:57 AM, EDUARDO CABRERA GRANADO <>

> Dear meep developers and users,
> first, I would like to thank meep developers for their work on this
> wonderful tool and the effort shown to get a Python interface, both in the
> code and in the documentation. I think it is a big push to increase the use
> of meep in electromagnetic simulations.
> Second, I would like to ask a question I have not seen answered anywhere
> (sorry in advance if it is somewhere I did not see). In short, I would like
> to know if it is possible to modify a parameter of the material used in a
> simulation continuously during the execution. More especifically, I would
> like to change the gamma and fn parameters of the DrudeSusceptibility with
> a step function, somehow in a similar way as change_sources function for
> the sources.
> I tried with a step function like:
> def change_susc(sim):
>     t = meep.Simulation.meep_time(sim)
>     fn = t*0.2
>     susc = [meep.DrudeSusceptibility(frequency=fn,gamma=0.1, sigma=0.1)]
>     mat = meep.Medium(epsilon=1.0, E_susceptibilities=susc)
>     geom = [meep.Sphere(radius=0.025,center=meep.Vector3(0,0,0),
> material=mat)]
>     sim.geometry=geom
>     meep.Simulation._init_structure(sim)
>     return sim
> meep.at_time(10,change_mat),
>         meep.at_end(meep.output_epsilon),until=60)
> The values are just for this example. Anyway, I must be doing something
> wrong so I tried to simplify the problem with a material with no dispersion
> and modifying the value of epsilon but again nothing happens.
> At this point, I do not know if I am doing something wrong or it is just
> that is not possible to change the material properties during simulation in
> Meep. If someone could provide some suggestion I would be very grateful.
> Thanks in advance.
> Eduardo
> _______________________________________________
> meep-discuss mailing list
meep-discuss mailing list

Reply via email to