sebastiaagramunt / micromagnetics Goto Github PK
View Code? Open in Web Editor NEWA package for micromagnetism in python
License: MIT License
A package for micromagnetism in python
License: MIT License
Current docker files Dockerfile
and makefile for docker are based on a previous package version. We now install things on poetry, we may change the images and write proper documentation
Need to implement the derivatives to calculate the exchange energy/field.
def derivative_coefficients(stencil: List[float], deg: int):
"""
Calculates the coefficients for the numerical derivative
Inputs:
deg: int -> the max degree of the derivatives
Output:
The coefficients to calculate the derivative at one point.
Refs:
http://web.media.mit.edu/~crtaylor/calculator.html
https://en.wikipedia.org/wiki/Finite_difference_coefficient
"""
# calculating finite difference coefficients for arbitrary stencil
# see section arbitrary stencil in https://en.wikipedia.org/wiki/Finite_difference_coefficient
N = len(stencil)
stencil_matrix = np.zeros((N, N), dtype=np.int64)
for i, j in [(x, y) for x in range(N) for y in range(N)]:
stencil_matrix[i][j] = pow(stencil[j], i)
stencil_matrix_inv = np.linalg.inv(stencil_matrix)
v = np.array(
[0 if i != deg else np.math.factorial(deg) for i in range(N)], dtype=np.int
)
return stencil_matrix_inv.dot(v)
def numeric_derivative(target_fn: Callable, stencil: List[float], a: float, h: float, deg: int):
"""
Calculate numerical d derivative at point a using points in self.strencil
Input:
a: point where we want to calculate the derivative
h: separation between evaluation points
deg: degree of the numeric derivative
"""
coeffs = derivative_coefficients(deg)
res = 0
for s, coef in zip(stencil, coeffs):
res += coef * target_fn(a + s * h) / pow(h, deg)
return res
Numeric derivative here calculates the derivative of a callable function at at a point a using a stencil. The idea is to adapt this code to calculate the derivative of the magnetisation at the center of a cell i. Initially in a regular grid (also with edges) and then as a general grid with a different stencil.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.