DamCB / tyssue-demo

Small demo notebooks for tyssue
Mozilla Public License 2.0
4 stars 2 forks source link

specs definitions #11

Open Mobinati opened 5 months ago

Mobinati commented 5 months ago

I am using Tyssue, and It's well-structured. thanks a lot. Just had a question, how is it possible to define the specs like prefered_area or prefered_perimeter not be unique for all cells in the tissue. how can we apply the energy minimization in a way that prefered_area or prefered_area be defined by a function and be specific for each cell?

sheet = Sheet.planar_sheet_2d('flat', 30, 30, 1, 1, noise=0.2)
to_cut = sheet.cut_out([(0.1, 6), (0.1, 6)])
sheet.remove(to_cut, trim_borders=True)
sheet.sanitize(trim_borders=True)
geom.center(sheet)
geom.update_all(sheet)
sheet.update_rank()
model = model_factory(
    [
        effectors.LineTension,
        effectors.FaceContractility,
        effectors.FaceAreaElasticity
    ]
)

specs = {
    "face": {
        "contractility": 5e-2,
        "prefered_area": sheet.face_df.area.mean(),
        "area_elasticity": 1.
    },
    "edge": {
        "line_tension": 1e-2,
        "is_active": 1
    },
    "vert": {
        "is_active": 1
    },
}
glyg commented 5 months ago

Hi @Mobinati thank your for your interest in using tyssue!

Specs are used to set default uniform values for the parameter, but you can later change those for specific cells by updating the value in the sheet.face_df dataframe. For example, if you want the central cell to have a prefered area that depends on some function of their position, you can run:

sheet.face_df["prefered_area"] = A0 * sheet.face_df['x']**2

Of course this is an artificial example ;) The important point is that what's used in the computation of the energy terms for example depends on the values in the face_df, edge_df and vert_df dataframes, and you can change the parameter values on any line of those pandas dataframes.

Hope this helps,

Best G

Mobinati commented 4 months ago

thanks a lot for the hint, actually I made a Custome function which works fine. but I have another issue with periodic boundaries.

how can I have a square box with cells connected to their front sides? for example for this tissue:

sheet = Sheet.planar_sheet_2d(
    'basic2D', # a name or identifier for this sheet
    nx=20, # approximate number of cells on the x axis
    ny=20, # approximate number of cells along the y axis
    distx=1, # distance between 2 cells along x
    disty=1 # distance between 2 cells along y
)
sgeom.update_all(sheet)

I already have tried these but didn't work.

spec["settings"].update({"boundaries": {"x": [1, 18], "y": [1, 18]}})

sheet = Sheet("periodic", model_specs)