# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # Line object

# +
import discretisedfield as df
import matplotlib.pyplot as plt
import numpy as np

mesh = df.Mesh(p1=(-10e-9, -10e-9, -10e-9), p2=(15e-9, 10e-9, 5e-9), cell=(1e-9, 1e-9, 1e-9))

def value_fun(point):
    x, y, z = point
    c = 1e9
    if x < -5e-9:    
        return (0, y*c, z*c)
    else:
        return (x*c, 2*y*c, 3*z*c)

field = df.Field(mesh, dim=3, value=value_fun, norm=1e6)

line = field.line(p1=(-10e-9, 0, 0), p2=(10e-9, 0, 0), n=30)
# -

line

line.dim

line.length

line.mpl(marker='o')

line.slider()

line.length


@df.interact(xlim=line.slider(),
             yaxis=line.selector())
def myplot(xlim, yaxis):
    return line.mpl(figsize=(10, 6), yaxis=yaxis, marker='o', xlim=xlim)

StarcoderdataJupyterScriptsDedupFiltered