user: Show practical ways to work with Liquid in a Blender add-on or script – include code.

assistant: Liquid settings control the behavior of the particles which the simulation consists of.
Enabling the liquid checkbox will automatically create a particle system for the simulation.
This particle system visualizes the flow of the simulation. Visualizing the liquid particles is optional.
The fluid simulation will make use of all the fields without an attached particle system too.

Simulation Method
:   Determines the liquid particle simulation method.

    FLIP:
    :   (FLuid Implicit Particle)
        Produces a very splashy simulation with lots of particles dispersed in the air.

    APIC:
    :   (Affine Particle-In-Cell)
        Produces a very energetic but also more stable simulation.
        Vortices within the liquid will be preserved better than with *FLIP*.

FLIP Ratio Simulation FLIP Only:
:   How much FLIP velocity to use when updating liquid particle velocities. A value of 1.0
    will result in a completely FLIP based simulation. Completely FLIP based simulations
    produce more chaotic splashes and are preferable when simulating greater quantities of liquid.
    When using smaller values the behavior will be less turbulent and splashes are more subtle.
    This is optimal when simulating scenes where the liquid is supposed to be on a small scale.

System Maximum
:   Maximum number of fluid particles that are allowed in the simulation. If this field is set to a nonzero value
    the simulation will never contain more than this number of fluid particles. Otherwise, with a value of zero
    the solver will always sample new particles when needed.

Particle Radius
:   The radius of one liquid particle in grid cells units. This value describes how much area is covered
    by a particle and thus determines how much area around it can be considered as liquid.
    A greater radius will let particles cover more area. This will result in more grids cell being tagged
    as liquid instead of just being empty.

    Whenever the simulation appears to leak or gain volume in an undesired, non physically accurate way it is
    a good idea to adjust this value. That is, when liquid seems to disappear this value needs to be increased.
    The inverse applies when too much liquid is being produced.

Sampling
:   Factor that is used when sampling particles. A higher value will sample more particles.
    Note that particle resampling occurs at every single simulation step.

Randomness
:   New particles are sampled with some randomness attached to their position
    which can be controlled by this field. Higher values will sample the liquid particles more
    randomly in inflow regions. With a value of 0.0 all new particles will be sampled uniformly inside
    their corresponding grid cells.

    When trying to create a laminar inflow (with little randomness) or more turbulent flows
    (with greater randomness) this value can be useful.

Particles Maximum
:   The maximum number of liquid particles per grid cell. During a simulation the number of liquid
    particles in a cell can fluctuate: Particles can flow into other cells or can get deleted
    if they move outside the narrow band. Resampling will add new particles considering this maximum.

    This value sets the upper threshold of particles per cell. It is also a good way to estimate how
    many particles there can be in your simulation (one needs to take grid resolution into account too).
    This can be useful before baking and when planning a simulation.

Minimum
:   The minimum number of liquid particles per grid cell. Similarly to the maximum particle threshold,
    this value ensures that there are at least a certain amount of particles per cell.

Narrow Band Width
:   Controls the width in grid cell units of the narrow band that liquid particles are allowed to flow in.
    A high value will result in a thicker band and can result in an inflow region completely filled
    with particles. Unless the goal of the simulation is to visualize the liquid particles it is
    recommended to not increase the band width significantly as more particles slow down the simulation.

    In some situations increasing this value can help create volume when the simulation appears to leak.
    In all other cases it is best to keep the narrow band as thin as possible since the liquid surface
    contains most details and simulating particles inside the liquid is not an optimal use of computing resources.

Fractional Obstacles
:   Enables finer resolution in fluid / obstacle regions (second order obstacles).
    This option reduces the “stepping effect” that results when an obstacle lies inclined inside the domain.
    It also makes liquid flow more smoothly over an obstacle.

    Obstacle Distance
    :   Determines how far apart fluid and obstacles are. This value can be used to achieve a more fluid motion over
        inclined obstacles: Depending on the slope of the obstacle increasing this value can help liquid particles
        flow better over an obstacle.
        Setting this field to a negative value will let fluid move towards the inside of an obstacle.

    Obstacle Threshold
    :   Value to control the smoothness of the fractional obstacle option. Smaller value reduce
        the “stepping effect” but may result particles sticking to the obstacle.

Bake Data, Free Data
:   This option is only available when using the [Modular](cache.html#bpy-types-fluiddomainsettings-cache-type) cache type.
    *Bake Data* simulates and stores the base of the fluid simulation on drive.
    Both gas and liquid simulations can add refinements on top of this
    (e.g. gas simulations can add noise, liquid simulations can add a mesh or secondary particles or both).

    The progress will be displayed in the status bar. Pressing `Esc` will pause the simulation.

    Once the simulation has been baked, the cache can be deleted by pressing *Free Data*.
    It is possible to pause or resume a *Bake All* process.