Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time Dependent Applied Field #31

Closed
Kyroba opened this issue Sep 4, 2023 · 6 comments
Closed

Time Dependent Applied Field #31

Kyroba opened this issue Sep 4, 2023 · 6 comments

Comments

@Kyroba
Copy link

Kyroba commented Sep 4, 2023

I was wondering if there could be a method to investigate time dependent external fields?

You could potentially solve the system for 1 field, then use the final state as the seed for the next field. However, this can quickly become tedious. Is there a simpler solution available to keep it all in 1 file?

Thank you!

@Kyroba
Copy link
Author

Kyroba commented Sep 4, 2023

I read the documentation for screening:

image

But I am not sure what values to give for alpha and beta.

@loganbvh
Copy link
Owner

loganbvh commented Sep 4, 2023

The values for alpha and beta will affect the rate of convergence, but should not affect the accuracy of results very much. I would just start with the default values. To be honest, the screening calculation slows things down so much that it is not all that useful, especially for large meshes.

I will try to add time-dependent applied vector potential soon. There are a few details I need to think about

@loganbvh
Copy link
Owner

loganbvh commented Sep 5, 2023

I remember now that you mentioned you have a GPU in your PC. The screening calculation is the one part of tdgl that can be accelerated using a GPU. This requires the JAX library from google (https://github.com/google/jax), which on Windows can be only be installed under Windows Subsystem for Linux (WSL). Calculating screening on the GPU requires storing a dense matrix of size num_edges X num_sites, which takes a lot of memory for large meshes.

@loganbvh
Copy link
Owner

loganbvh commented Sep 6, 2023

I started a branch to work on time-dependent applied vector potential: 33989b0. I need to update the documentation and tests before merging the change, but you are welcome to try it on the time-dependent-field branch in the meantime. Happy to hear any feedback you have on this

Example

The simplest way to define a time-dependent applied field is to multiply an existing tdgl.Parameter for a time-independent applied vector potential (e.g. tdgl.sources.ConstantField or tdgl.sources.CurrentLoop by a time-dependent scale factor, for example a linear ramp from zero up to some value.

Using the model from the quickstart notebook:

from tdgl import sources

options = tdgl.SolverOptions(
    solve_time=500,
    output_file="weak-link-zero-current.h5",
    field_units = "mT",
    current_units="uA",
    dt_max=1e-2,
)

# Ramp the applied field from 0 to 1 mT between t=0 and t=200, then hold it at 1 mT.
A_applied = (
    sources.LinearRamp(tmin=0, tmax=200)
    * sources.ConstantField(1, field_units=options.field_units, length_units=device.length_units
)

zero_current_solution = tdgl.solve(
    device,
    options,
    applied_vector_potential=A_applied,
)
weak-link-zero-current.mp4

More details

You can also directly define a time-dependent tdgl.Parameter, as in A_applied = tdgl.Parameter(some_function, time_dependent=True, **kwargs), where some_function has a signature like some_function(x, y, z, *, t, **kwargs) and t is the dimensionless time which must be a keyword only argument.

Including a time-dependent applied vector potential slows things down a bit. This is because each time the applied vector potential changes, I have to update the link variables in the covariant gradient and Laplacian for \psi. Updating all of these elements of a sparse matrix takes some time.

@Kyroba
Copy link
Author

Kyroba commented Sep 6, 2023

Very nice! The initialization of more vortices as the field increases looks great!

@loganbvh
Copy link
Owner

loganbvh commented Sep 9, 2023

I am going to close this issue because I have merged #33, which adds support for time-dependent vector potentials

@loganbvh loganbvh closed this as completed Sep 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants