Manipulating fields

Here are some functions that fieldkit contains to manipulate a field. Lets start by initializing a field.

[1]:
import fieldkit as fk

field = fk.Field(npw=(32,32))

# create a creepy face
fk.add_gaussian(field,center=(0.25,0.75),sigma=0.1)
fk.add_gaussian(field,center=(0.75,0.75),sigma=0.1)
fk.add_ellipse(field,center=(0.5,0.25), axis_lengths=(0.4,0.05), height=0.01)

fk.plot(field, dpi=100)
../_images/tutorials_02_manipulate_fields_1_0.png

Changing resolution

Here’s how you increase or decrease the resolution of a previously generated field

[2]:
# increase resolution
field_new = fk.change_resolution(field, npw_new=(64,64))
fk.plot(field_new,dpi=100)
Note: not plotting imaginary part of field 0
../_images/tutorials_02_manipulate_fields_3_1.png
[3]:
# decrease resolution
field_new = fk.change_resolution(field, npw_new=(16,16))
fk.plot(field_new,dpi=100)
Note: not plotting imaginary part of field 0
../_images/tutorials_02_manipulate_fields_4_1.png

Replicating fields

[4]:
field_new = fk.replicate_fields(field,(3,2))
fk.plot(field_new, dpi=100)
../_images/tutorials_02_manipulate_fields_6_0.png

Translate fields

[5]:
field_new = fk.roll(field,shift=(0.25,0)) # translate by 1/4 box length to right
fk.plot(field_new, dpi=100)
../_images/tutorials_02_manipulate_fields_8_0.png

Expand dimension

It is common to first start with a field in 1d (e.g. SCFT of LAM), but would like to extend it higher dimensions (e.g. to run complex Langevin). Here’s how you do that:

[6]:
fields_1d = fk.read_from_file('density_1d_LAM.dat') #read 1d fields

# expand to 2d
fields_2d = fk.expand_dimension(fields_1d, dim_new=2, npw_new=[32], boxl_new=[5.0])
fk.plot(fields_2d)
Note: not plotting imaginary part of field 0
Note: not plotting imaginary part of field 1
../_images/tutorials_02_manipulate_fields_10_1.png
[7]:
# expand to 3d
fields_3d = fk.expand_dimension(fields_1d, dim_new=3, npw_new=[32,32], boxl_new=[5.0, 8.0])
fk.plot(fields_3d)
Note: not plotting imaginary part of field 0
Note: not plotting imaginary part of field 1
../_images/tutorials_02_manipulate_fields_11_1.png