def check_def_topol_consistency(dic_Cname2Hnames, lipid_top):
    """Check the consistency between the lipid topology and the def file.

    Ensure that the carbons in the def file are present in the topology.
    Ensure that all hydrogens of a given carbon as described in the
    topology are present in the def file.

    Parameters
    ----------
    dic_Cname2Hnames : dictionary
        This dictionary gives the correspondance Cname -> Hname. It is a dictionary of
        tuples extracted from the def file.
    lipid_top : dictionary
        lipid topology for hydrogen.

    Returns
    -------
    Bool
        True is it's coherent. False otherwise.
    """
    # Check if carbons in dic_Cname2Hnames keys are all present in the lipid
    # topology.
    if not set(dic_Cname2Hnames.keys()).issubset(lipid_top.keys()):
        miss_atoms = ",".join(set(dic_Cname2Hnames.keys()) - set(lipid_top.keys()))
        print(f"Some carbons ({miss_atoms}) from the definition file are not"
              "present in the json file.")
        return False

    # For each carbon in topology, make sure all hydrogens attached
    # are in the def file
    nb_Hs_expected = {'CH3': 3, 'CH2': 2, 'CH': 1, 'CHdoublebond': 1}
    for carbon, values in lipid_top.items():
        if carbon != "resname":
            H_type = values[0]
            nb_Hs_topol = nb_Hs_expected[H_type]
            if carbon in dic_Cname2Hnames: # Handle partial def file
                nb_Hs_def = len(dic_Cname2Hnames[carbon])
                if nb_Hs_def != nb_Hs_topol:
                    print(f"Carbon {carbon} from the definition file should contains "
                        f"{nb_Hs_topol} hydrogen(s), found {nb_Hs_def}.")
                    return False
    return True