Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rearrangement (T1&T3) with QS Solver #257

Open
sophietheis opened this issue Aug 16, 2022 · 6 comments
Open

Rearrangement (T1&T3) with QS Solver #257

sophietheis opened this issue Aug 16, 2022 · 6 comments

Comments

@sophietheis
Copy link
Collaborator

Hi,

I proceed to some cell rearrangement with a 2D sheet, and the QSSolver. It seems to me that rearrangement proceed in the solver directly doesn't work very well compare to the ones proceed with the manager. And at the end, tissue looks to be more physiologic with the manager.

As example, the initial state:
image

With T1&T3 proceed with QSSolver:
image

With the manager:
image

Should we put as deprecated with_t1 and with_t3 parameters functions in the QSSolver as it is for the EulerSolver ? If yes, I can do it in the next PR.

Sophie

@glyg
Copy link
Member

glyg commented Aug 18, 2022

oh yes there clearly is a bug there, can you post the code to reproduce?
If you switch off with_t1 and with_t3 is it better?

@sophietheis
Copy link
Collaborator Author

When I use the manager to perform T1, I switch off with_t1 and with_t3, so it is better.

Here is the code :

def sheet_init(nx, ny, gamma_0=0.5, phi=np.pi / 2, noise=0.2):
    sheet = Sheet.planar_sheet_2d(
        'sheet', nx=nx, ny=ny, distx=1, disty=1, noise=noise)
    # Cut at the border to avoid strange cells
    to_cut = sheet.cut_out([(0.1, nx), (0.1, ny)])
    sheet.update_specs({"edge": {"gamma_0": gamma_0,
                                 "phi0": phi},
                        })
    geom.update_all(sheet)
    sheet.remove(to_cut, trim_borders=True)
    sheet.sanitize(trim_borders=True)
    geom.update_all(sheet)

    # Center sheet to (0,0)
    geom.center(sheet)

    geom.update_all(sheet)
    sheet.edge_df["opposite"] = sheet.get_opposite()
    return sheet, geom

nx = 20
ny = 20
noise = 0.3
gamma_0 = 0.
phi_apical = np.pi/2
phi_basal = 0

apical_sheet, geom = sheet_init(nx, ny, gamma_0, phi_apical, phi_basal, noise)

apical_sheet.get_opposite()
    
apical_sheet.update_specs({"settings":{"dt":0.01,
                                     'threshold_length': 0.01,
                                     'p_4': 0.1,
                                     'p_5p': 0.01,}})

apical_sheet.face_df['prefered_area'] = 1.
apical_sheet.face_df['area_elasticity'] = 1.
apical_sheet.face_df['prefered_perimeter'] = 3*np.sqrt(apical_sheet.face_df['prefered_area'] )
apical_sheet.face_df['perimeter_elasticity'] = 1.
apical_sheet.vert_df['viscosity'] = 1.0
apical_sheet.edge_df['is_active'] = 1

apical_sheet_init = apical_sheet.copy(deep_copy=True)

#T1 with Solver
apical_sheet = apical_sheet_init.copy(deep_copy=True)
# Solver
solver_qs = QSSolver(with_t1=True, with_t3=True, with_collisions=False)

# Model
model = model_factory(
    [
        effectors.FaceAreaElasticity,
        effectors.PerimeterElasticity,
    ])
for i in range(20):
#     print(i)
    res = solver_qs.find_energy_min(apical_sheet, PlanarGeometry, model, periodic=False, options={"gtol": 1e-8})
    if res.success is False:
        print (res)
    apical_sheet.vert_df[["x", "y"]] += np.random.normal(scale=1e-3, size=(apical_sheet.Nv, 2))
    PlanarGeometry.update_all(apical_sheet)
    
#T1 with Manager
apical_sheet = apical_sheet_init.copy(deep_copy=True)
# Solver
solver_qs = QSSolver(with_t1=False, with_t3=False, with_collisions=False)
# Manager
manager = EventManager('face')
manager.append(reconnect)
# Model
model = model_factory(
    [
        effectors.FaceAreaElasticity,
        effectors.PerimeterElasticity,
    ])
for i in range(20):
    manager.execute(apical_sheet)
    res = solver_qs.find_energy_min(apical_sheet, PlanarGeometry, model, periodic=False, options={"gtol": 1e-8})
    if res.success is False:
        print (res)
    apical_sheet.vert_df[["x", "y"]] += np.random.normal(scale=1e-3, size=(apical_sheet.Nv, 2))
    PlanarGeometry.update_all(apical_sheet)
    manager.update()

@sophietheis
Copy link
Collaborator Author

Hi,

It seems that with a planar monolayer, there is some issue when running reconnect function with the manager (I don't try using T1 with QS solver). Apical vertex sometime loose connection with the basal/lateral vertex (or vice versa).
From what I see until now, I would say it comes from _OI_transition function, but does't seem to append everytime this function is called. I keep digging to find the condition which cause the problem.
Have you already got this issue ?

@glyg
Copy link
Member

glyg commented Aug 23, 2022

HI, yes I think there is a bug in _OI_transition, I tried to fix it but could not find the actual issue... And I don't have time right now (deadlines on the 8th of september) Cool if you can look.
I refactored the code to use pd.concat instead of append and maybe the bug came from that. Maybe look if some NaN appear in face_df or edge_df ?

@sophietheis
Copy link
Collaborator Author

No problem, I have time now to look at it.
It doesn't come from using concat instead of append and there is no NaN value.
I think it cames from connected, which reassign vertex for too much edges, as I try to show here:
image

Solution is closed, I will do a PR when I have it.

@glyg
Copy link
Member

glyg commented Aug 23, 2022

great!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants