InitField

It is possible to initialize either the exchange fields or species fields within a model.

Initializing exchange fields

When initializing exchange fields, the names of the fields will depend on the Model you are using. For example, for ModelChiAB:

fts.model = openfts.model.ChiAB( ...)

# exchange fields
fts.model.init_fields['mu_minus'] = openfts.init_field.Random(mean=0.0,stdev=1.0)
fts.model.init_fields['mu_plus'] = openfts.init_field.Random(mean=0.0,stdev=1.0)

Or for ModelChiMultiSpecies:

fts.model = openfts.model.ChiMultiSpecies( ...)

# exchange fields
fts.model.init_fields['mu_1'] = openfts.init_field.Random(mean=0.0,stdev=1.0)
fts.model.init_fields['mu_2'] = openfts.init_field.Random(mean=0.0,stdev=1.0)
fts.model.init_fields['mu_3'] = openfts.init_field.Random(mean=0.0,stdev=1.0)

Note

If you are having trouble determining the names of the exchange fields for your current model, try removing the fts.model.init_fields lines from your input file and run OpenFTS. The names of the exchange fields for your current model will be output to the log.

Initializing species fields

It is generally conceptually more clear to initialize the species fields of the model. . One advantage of this approach is that this initialization will be independent of Model. Another advantage is that the species fields are generally easier to understand physically: the density of a species will be large where the species field is low. To initialize the using a species field, you will specify the name of the field that is consistent with that species’ label specified by Species(label=’A’). For example:

# species fields
fts.species.append(openfts.Species(label='A', ...))
fts.species.append(openfts.Species(label='B', ...))
fts.model.init_fields['mu_A'] = ... # 'mu_A' is consistent with Species(label='A') above
fts.model.init_fields['mu_B'] = ... # 'mu_B' is consistent with Species(label='B') above

Ways to initialize exchange/species fields

class openfts.init_field.Gaussian(ngaussian=None, centers=[], height=None, width=None)

Used by Model to initialize a field using Gaussians

Parameters:
  • ngaussian (int) – number of Gaussians to add

  • centers (2d list of floats) – Locations of Gaussian centers. Length of 1st dimension should be the number of gaussians, length of 2nd dimension should be dimension of simulation cell

  • height (float) – height of Gaussian to add

  • width (float) – width of Gaussian to add

(python):

# for ChiAB in 2D cell
fts.model = openfts.model.ChiAB( ...)
fts.model.init_fields['mu_minus'] = openfts.init_field.Gaussian(height=1.0,ngaussian=2,width=0.1,
                                                                centers=[[0,0],[0.5,0.5]])

json:

"model": {
  "type": "MeltChiAB"
  ...
  "initfields": {
    "mu_minus": {
      "center0": [ 0,0 ],
      "center1": [ 0.5,0.5 ],
      "height": 1.0,
      "ngaussian": 2,
      "type": "gaussians",
      "width": 0.1
    }
    ...
  },
  ...
}
class openfts.init_field.Random(mean=None, stdev=None)

Used by Model to initialize a field randomly

Parameters:
  • mean (float) – Mean of the randomly generated field

  • stdev (float) – Standard deviation of the randomly generated field

(python):

# for ChiMultiSpecies
# exchange fields
fts.model.init_fields['mu_1'] = openfts.init_field.Random(mean=0.0,stdev=1.0)
fts.model.init_fields['mu_2'] = openfts.init_field.Random(mean=0.0,stdev=1.0)
fts.model.init_fields['mu_3'] = openfts.init_field.Random(mean=0.0,stdev=1.0)

# species fields
fts.model.init_fields['mu_A'] = openfts.init_field.Random(mean=0.0,stdev=1.0)
fts.model.init_fields['mu_B'] = openfts.init_field.Random(mean=0.0,stdev=1.0)
fts.model.init_fields['mu_C'] = openfts.init_field.Random(mean=0.0,stdev=1.0)

json:

"model": {
  "type": "MeltChiAB"
  ...
  "initfields": {
    "mu_plus": {
      "type": "random",
      "mean": 0.0,
      "stdev": 1.0
    }
    ...
},
class openfts.init_field.FromFile(filename, field_type='exchange')

Initializes a set of fields from a file for Model

Parameters:
  • filename (string) – Initialize fields by reading from filename

  • field_type (string) – Types of fields to read from the file, species or exchange. Default is exchange

python

import openfts
fts = openfts.OpenFTS()
...
field_filename="exchange_fields.in"
fts.model.init_fields = openfts.init_field.FromFile(filename=field_filename,field_type='exchange')
...

json

"model": {
  "type": ...
  ...
  "initfields": {
    "field_type": "exchange",
    "file":"exchange_fields.in"
  },
  ...
},