From d61577441e8b38c7f6caaffb79408be4ded9c0e2 Mon Sep 17 00:00:00 2001 From: Eric Fayolle Date: Tue, 7 May 2019 19:17:40 +0200 Subject: [PATCH] =?utf8?q?G=C3=A9n=C3=A9ration=20du=20fichier=20em.mdp?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Vimmp/cata_Vimmp.py | 17 ++--- Vimmp/cata_gromacs.py | 137 +++++++++++++++++++++++++---------- Vimmp/create_em.mdp.py | 44 +++++++++++ Vimmp/gromacs_em+nvt_v1.comm | 82 +++++++++++++++++++++ 4 files changed, 231 insertions(+), 49 deletions(-) create mode 100644 Vimmp/create_em.mdp.py create mode 100644 Vimmp/gromacs_em+nvt_v1.comm diff --git a/Vimmp/cata_Vimmp.py b/Vimmp/cata_Vimmp.py index d708ce2e..15015dd9 100644 --- a/Vimmp/cata_Vimmp.py +++ b/Vimmp/cata_Vimmp.py @@ -8,7 +8,9 @@ monFile=os.path.abspath(__file__) # ------------------------------------------------- Definition fonction utilisateur from Accas import * class Elementary_Surface(UserASSD): pass -class StudySD(ASSD) : pass +class CDM_SD(ASSD) : pass +# class CodeSpecific(ASSD) : pass +class SPM_SD(ASSD) : pass class Specie(UserASSD) : pass class BondedParticle(UserASSD) : pass @@ -81,7 +83,7 @@ def BlocPourLesFichiers (laCondition, NomDuFichier, ListeFormats): JdC = JDC_CATA(code='Vimmp',fichierSource=monFile) -Study = OPER(nom = 'Study', sd_prod = StudySD, +CDM = OPER(nom = 'CDM', sd_prod = CDM_SD, Title = SIMP( statut='o', typ='TXM'), Simulated_Time_Lapse = FACT( statut='o', Initial_Time = SIMP( statut='o', typ='R'), @@ -340,7 +342,7 @@ Study = OPER(nom = 'Study', sd_prod = StudySD, #-----------------------------------------------------# Type_Of_Boundary_Condition = SIMP( statut='o', typ='TXM', into=['Inlet', 'Outlet', 'Symmetry','Periodic', 'Wall'], position='global'), b_periodique = BLOC( condition = "Type_Of_Boundary_Condition == 'Periodic'", - Direction = SIMP( statut='o', typ='TXM', into=['X','Y','Z', 'all']), + Direction = SIMP( statut='o', typ='TXM', into=['X','Y','Z', 'XYZ']), ), # b_periodique b_non_periodique = BLOC( condition = "Type_Of_Boundary_Condition != 'Periodic'", @@ -389,17 +391,10 @@ Study = OPER(nom = 'Study', sd_prod = StudySD, # ),# Initial_Condition_For_Each_Variable # ), # b_Globale ), # Initials_Conditions -) # Study +) # CDM -Run_Option = PROC( nom='Run_Option', - MyStudy = SIMP( statut='o', typ=StudySD ), - Working_Dir = SIMP( statut='f', typ='TXM'), # - Number_Of_Time = SIMP( statut='o', typ='I'), - )# Run_Option - - # a refaire en reprenant # # lennard_jones si MD et groot_warren DPD diff --git a/Vimmp/cata_gromacs.py b/Vimmp/cata_gromacs.py index 4ce90209..e59446bd 100644 --- a/Vimmp/cata_gromacs.py +++ b/Vimmp/cata_gromacs.py @@ -1,56 +1,117 @@ from cata_Vimmp import * -CodeSpecific=PROC(nom='CodeSpecific', - Gromacs_Physical_Description = FACT(statut='o', - Constraints = FACT(statut = 'o', - # pour Gromacs, rien = linear - Recalage_Centre_Gravite_Type = SIMP(statut='o', typ ='TXM', into =['Linear', 'Angular', 'Non Activ'], defaut = 'Non Activ'), - b_recalage_cgt = BLOC (condition = "recalage_centre_gravite_type != 'Non Activ'", - Porte_Sur_Tout_Le_Systeme = SIMP ( statut ='o', typ = bool, defaut = True), - b_porte_sur_tout_le_system = BLOC( condition = 'Porte_Sur_Tout_Le_Systeme == False ', - Liste_Des_Groupes = SIMP ( statut ='o', typ = 'TXM', max= '**'), - ), # b_porte_sur_tout_le_system - ),# b_recalage_cgt - ), # Constraints - T_Coupling = SIMP(statut='o', typ ='TXM',into =['Non Activ', 'Berendsen','Nos-Hoover','Andersen','Andersen-Massive','V-Rescale'],position='global', defaut = 'Non Activ'), - b_t_coupling = BLOC(condition = "T_Coupling != 'Non Activ'", - Groups_Separatly_Coupled = SIMP(statut='o', typ = bool, defaut = False), - b_groups_separatly_coupled = BLOC(condition = "Groups_Separatly_Coupled == True", - TC_Group_Param = FACT(statut='o', max ='**', - Name_Of_Group = SIMP(statut='o', typ ='TXM'), - Tau_T = SIMP(statut='o', typ ='R'), - b_tau_t = BLOC(condition = "tau_t != -1", - Ref_T = SIMP(statut='o', typ ='R'), - ), # b_tau_t - ), # tc_group_param - ),#b_groups_separatly_coupled - ), # b_t_coupling - Velocity_Generation = SIMP(statut='o', typ = bool, defaut = False), - b_Velocity_Generation = BLOC(condition = "Velocity_Generation == True", +#CodeSpecific=OPER(nom='CodeSpecific', sd_prod = SPM_SD, +CodeSpecific=PROC(nom='CodeSpecific', + # Gromacs_Physical_Description = FACT(statut='o', + + gen_vel = SIMP(statut='o', typ = bool, defaut = False), + b_Velocity_Generation = BLOC(condition = "gen_vel == True", gen_temp = SIMP(statut='o', typ='R', ang='temperature for Maxwell distribution'), gen_seed = SIMP(statut='o', typ='R', ang='used to initialize random generator,when -1 a pseudo random seed is used', defaut = -1), ), - ), # Gromacs_Physical_Description + + Gromacs_Physical_Constraints = FACT(statut = 'o', + # pour Gromacs, rien = linear + Remove_Center_Of_Mass_Motion = SIMP(statut='o', typ ='TXM', into =['Linear', 'Angular', 'Non Activ'], defaut = 'Non Activ'), + b_recalage_cgt = BLOC (condition = "Remove_Center_Of_Mass_Motion != 'Non Activ'", + Apply_On_The_Complete_System = SIMP ( statut ='o', typ = bool, defaut = True), + b_porte_sur_tout_le_system = BLOC( condition = 'Apply_On_The_Complete_System == False ', + List_Of_Groups = SIMP ( statut ='o', typ = 'TXM', max= '**'), + ), # b_porte_sur_tout_le_system + ),# b_recalage_cgt + + Bond_Constraints = FACT(statut = 'o', + Bond_Constraint_Type = SIMP(statut='o', typ ='TXM', into =['BC_none', 'h-bonds', 'all-bonds', 'h-angles', 'all-angles'], defaut = 'BC_none'), + # We decided not to use < defaut = 'LINCS' > to avoid displaying the conditional block whithout + # displaying the value of Bond_Constraint_Algorithm + Bond_Constraint_Algorithm = SIMP(statut='f', typ ='TXM', into =['LINCS', 'SHAKE'], sug = 'LINCS'), + b_bond_constraint_algorithm_lincs = BLOC (condition = "Bond_Constraint_Algorithm == 'LINCS'", + #TODO : Use an optional xmlname='lincs-order' parameter to get the dash in xsd which is forbidden in python + lincs_order = SIMP ( statut ='o', typ= 'I', defaut = 4, ang="Highest order in the expansion of the constraint coupling matrix.\n When constraints form triangles, an additional expansion of the same order is applied on top of the normal expansion only for the couplings within such triangles.\n For 'normal' MD simulations an order of 4 usually suffices, 6 is needed for large time-steps with virtual sites or BD.\n For accurate energy minimization an order of 8 or more might be required.\n With domain decomposition, the cell size is limited by the distance spanned by lincs-order+1 constraints.\n When one wants to scale further than this limit, one can decrease lincs-order and increase lincs-iter, since the accuracy does not deteriorate when (1+lincs-iter)*lincs-order remains constant."), + #TODO : Use an optional xmlname='lincs-iter' parameter to get the dash in xsd which is forbidden in python + #Si Statistical_Physics_Equilibrium.Distribution == 'nve' we might propose a default to lincs_iter == 2 + lincs_iter = SIMP ( statut ='o', typ= 'I', defaut = 1,ang="Number of iterations to correct for rotational lengthening in LINCS.\n For normal runs a single step is sufficient, but for NVE runs where you want to conserve energy accurately or for accurate energy minimization you might want to increase it to 2."), + #TODO : Use an optional xmlname='lincs-warnangle' parameter to get the dash in xsd which is forbidden in python + lincs_warnangle = SIMP ( statut ='o', typ= 'I', defaut = 30, val_max=359, val_min=0, ang="[degrees] maximum angle that a bond can rotate before LINCS will complain"), + ),# b_bond_constraint_algorithm_lincs + + b_bond_constraint_algorithm_shake = BLOC (condition = "Bond_Constraint_Algorithm == 'SHAKE'", + #TODO : Use an optional xmlname='shake-tol' parameter to get the dash in xsd which is forbidden in python + shake_tol = SIMP ( statut ='o', typ= 'R', defaut = 0.0001, ang="relative tolerance for SHAKE"), + ),# b_bond_constraint_algorithm_shake + Morse = SIMP(statut='f', typ ='TXM', into =['no', 'yes'], defaut = 'no'), + + ), # Bond_Constraints + + Temperature_Coupling = FACT(statut = 'o', + tcoupl = SIMP(statut='o', typ ='TXM',into =['Non Activ', 'Berendsen','Nos-Hoover','Andersen','Andersen-Massive','V-Rescale'],position='global', defaut = 'Non Activ'), + b_t_coupling = BLOC(condition = "tcoupl != 'Non Activ'", + Groups_Separatly_Coupled = SIMP(statut='o', typ = bool, defaut = False), + b_groups_separatly_coupled = BLOC(condition = "Groups_Separatly_Coupled == True", + #TODO : Use an translate name xmlname='tc-grps' parameter to get the dash in xsd which is forbidden in python and better name for users + # TC_Group_Param = FACT(statut='o', max ='**', + TC_Group_Param = FACT(statut='o', + Name_Of_Group = SIMP(statut='o', typ ='TXM'), + tau_t = SIMP(statut='o', typ ='R',ang="time constant for coupling (one for each group in tc-grps), -1 means no temperature coupling",nomXML='tau-t'), + b_tau_t = BLOC(condition = "tau_t != -1", + ref_t = SIMP(statut='o', typ ='R',ang="reference temperature for coupling (one for each group in tc-grps)"), + ), # b_tau_t + ), # tc_group_param + ),#b_groups_separatly_coupled + ), # b_t_coupling + ), # Temperature_Coupling + + ), # Gromacs_Physical_Constraints + + # ), # Gromacs_Physical_Description + + + Gromacs_Numerical_Description = FACT(statut='o', + Integrator = SIMP(statut='o',typ='TXM', into=['steep','md'] ), + b_steep = BLOC(condition = " Integrator == 'steep'", + emtol = SIMP(statut='o', typ='R', ang="(10.0) [kJ mol-1 nm-1] the minimization is converged when the maximum force is smaller than this value",defaut = 10.0), + emstep=SIMP(statut='o', typ='R', ang="(0.01) [nm] initial step-size",defaut=0.001), + nstcgsteep=SIMP(statut='f', typ='I', ang="(1000) [steps] frequency of performing 1 steepest descent step while doing conjugate gradient energy minimization.",defaut=1000), + nbfgscorr=SIMP(statut='f', typ='I', ang="(10) [steps] Number of correction steps to use for L-BFGS minimization. A higher number is (at least theoretically) more accurate, but slower.",defaut=10), + ), + # Consigne = SIMP(statut ="o", homo="information", typ="TXM", defaut=''), # cf nb de step modele commun --> a decider Nb_Of_Steps = SIMP(statut='o', typ ='I', val_min = 1), - b_t_coupling_num = BLOC(condition = "T_Coupling != 'Non Activ'", - Nsttcouple = SIMP(statut ='o', typ='I',), + #EXO: Remonter ce parametre dans le FACT Temperature_Coupling + #TODO : Lier la valeur par defaut de nsttcouple a la valeur de nstlist pour la projection xsd + b_t_coupling_num = BLOC(condition = "tcoupl != 'Non Activ'", + nsttcouple = SIMP(statut ='o', typ='I', defaut=-1), ), ), Gromacs_Neighbor_Searching = FACT(statut = 'o', - Cutoff_Scheme = SIMP(statut='o', typ ='TXM', into = ['verlet','group']), - ), + cutoff_scheme = SIMP(statut='o', typ ='TXM', into = ['verlet','group'],), + #TODO : Analyser plus en details les valeurs par defaut possibles pour ce parametre + nstlist = SIMP(statut ='o', typ='I', defaut=10), + nst_type = SIMP(statut ='o', typ='TXM', into=['grid','simple'], defaut='grid'), + Consigne = SIMP(statut='o',typ='TXM',homo='information',defaut='pbc parameter comes from the common data model'), + #TODO : la relation a pbc n'est pas clair ds la doc + periodic_molecules = SIMP(statut ='o', typ=bool), + b_rlist = BLOC(condition = "cutoff_scheme == 'group'", + rlist = SIMP(statut ='o', typ='I', defaut=-1,ang="[nm]"), + ), + rcoulomb = SIMP(statut ='o', typ='R', defaut=1, val_min=0,ang="[nm] distance for the Coulomb cut-off"), + rvdw = SIMP(statut ='o', typ='R', defaut=1, val_min=0,ang="[nm] distance for the LJ or Buckingham cut-off"), + ), Gromacs_Run_Options = FACT(statut='o', + UserDef=SIMP(statut='f', typ='TXM', into=['-DFLEX_SRC',]), Files_Energy_Minimization = FACT(statut='o', - MD_Input_File = SIMP(statut='o', typ = ('Fichier','mdp Files (*.mdp);;All Files (*)')), - Structure_File = SIMP(statut='o', typ = ('Fichier','gro Files (*.gro);;All Files (*)')), + MDP_Initial_Input_File = SIMP(statut='o', typ = ('FichierNoAbs','mdp Files (*.mdp);;All Files (*)')), + Gromos_File = SIMP(statut='o', typ = ('Fichier','gro Files (*.gro);;All Files (*)')), # en entree de grompp et de mdrun option -c - Gromacs_Topology_File = SIMP(statut='o', typ = ('Fichier','Top Files (*.top);;All Files (*)')), - MD_File = SIMP(statut='o', typ = ('FichierNoAbs')), # doit finir par mdp + Gromacs_Topology_File = SIMP(statut='o', typ = ('Fichier','Top Files (*.top);;All Files (*)')), + MDP_File = SIMP(statut='o', typ = ('FichierNoAbs')), # doit finir par mdp # le MD_Output_File (-o pour grommp devient le -s de de mdrun) - XDR_Output_File = SIMP(statut='o', typ = ('FichierNoAbs')), # doit finir par tpr - log_File = SIMP(statut='f', defaut ='/tmp/EM.log', typ=('FichierNoAbs')), + Run_Input_File = SIMP(statut='o', typ = ('FichierNoAbs')), # doit finir par tpr + log_File = SIMP(statut='f', defaut ='/tmp/EM.log', typ=('FichierNoAbs')), + Energie_Output_File = SIMP(statut='f', typ = ('FichierNoAbs')), # doit finir par edr + Trajectory_Output_File = SIMP(statut='f', typ = ('FichierNoAbs')), # doit finir par trr + ), # Files_Energy_Minimization ), # Gromacs_Run_Options ) diff --git a/Vimmp/create_em.mdp.py b/Vimmp/create_em.mdp.py new file mode 100644 index 00000000..d6b427b7 --- /dev/null +++ b/Vimmp/create_em.mdp.py @@ -0,0 +1,44 @@ +#! /usr/bin/env python +# -*- coding:utf-8 -*- + +import cata_gromacs_genere as mdm +import pyxb + +#mdm.pyxb.GlobalValidationConfig._setContentInfluencesGeneration(mdm.pyxb.GlobalValidationConfig.NEVER) +mdm.pyxb.GlobalValidationConfig._setContentInfluencesGeneration(mdm.pyxb.GlobalValidationConfig.ALWAYS) +mdm.pyxb.GlobalValidationConfig._setInvalidElementInContent(mdm.pyxb.GlobalValidationConfig.RAISE_EXCEPTION) +mdm.pyxb.GlobalValidationConfig._setOrphanElementInContent(mdm.pyxb.GlobalValidationConfig.RAISE_EXCEPTION) + +jdd = mdm.CreateFromDocument(open('gromacs_em+nvt_v1.xml').read()) +print jdd.toDOM().toprettyxml() + +em_mdc=jdd.CDM[0] +em_spc=jdd.Code_Specific[0] +file_input_mdp_name=em_spc.Gromacs_Run_Options.Files_Energy_Minimization.MDP_Initial_Input_File +if os.access(file_input_mdp_name,os.R_OK) : txt=open(file_input_md_name).read() +else: txt="" + +txt+="define = "+str(em_spc.Gromacs_Run_Options.UserDef)+"\n" +txt+="integrator = "+str(em_spc.Gromacs_Numerical_Description.Integrator)+"\n" +txt+="nsteps = "+str(em_spc.Gromacs_Numerical_Description.Nb_Of_Steps)+"\n" +txt+="emtol = "+str(em_spc.Gromacs_Numerical_Description.emtol)+"\n" +txt+="emstep = "+str(em_spc.Gromacs_Numerical_Description.emstep)+"\n" +txt+="constraints = "+str((em_spc.Gromacs_Physical_Constraints.Bond_Constraints.Bond_Constraint_Type == 'BC_none') and 'none' or em_spc.Gromacs_Physical_Constraints.Bond_Constraints.Bond_Constraint_Type)+"\n" +txt+="cutoff-scheme = "+str(em_spc.Gromacs_Neighbor_Searching.cutoff_scheme)+"\n" +txt+="nstlist = "+str(em_spc.Gromacs_Neighbor_Searching.nstlist)+"\n" +txt+="ns_type = "+str(em_spc.Gromacs_Neighbor_Searching.nst_type)+"\n" +assert(em_mdc.Boundary_Conditions[0].Type_Of_Boundary_Condition == u'Periodic') + +txt+="pbc = "+str(em_mdc.Boundary_Conditions[0].Direction.lower())+"\n" +txt+="periodic_molecules = "+str(em_spc.Gromacs_Neighbor_Searching.periodic_molecules and 'yes' or 'no')+"\n" +txt+="rlist = "+str(em_spc.Gromacs_Neighbor_Searching.rlist)+"\n" +txt+="rcoulomb = "+str(em_spc.Gromacs_Neighbor_Searching.rcoulomb)+"\n" +txt+="rvdw = "+str(em_spc.Gromacs_Neighbor_Searching.rvdw)+"\n" + +file_output_mdp_name=em_spc.Gromacs_Run_Options.Files_Energy_Minimization.MDP_File +file_output_mdp = open( file_output_mdp_name, 'w') +file_output_mdp.write(txt) +file_output_mdp.close() + + + diff --git a/Vimmp/gromacs_em+nvt_v1.comm b/Vimmp/gromacs_em+nvt_v1.comm new file mode 100644 index 00000000..6c1c09b4 --- /dev/null +++ b/Vimmp/gromacs_em+nvt_v1.comm @@ -0,0 +1,82 @@ + +NanoTube12=CDM(Title='NanoTubeC53', + Simulated_Time_Lapse=_F(Initial_Time=0.0, + Duration=100.0,), + Geometric_Domain=_F(Shape='Simplified Shape', + Box='Cube', + Size_Of_Bounding_Box=(16.0,16.0,16.0), + Surface=('INT1','INT52',),), + System_Component=_F(General_Level_Of_Description='Mesoscopic', + Component='Classical_Particle System', + Physical_Description_Particle=_F(List_Of_Species=_F(Number_Of_Species=1, + Specie=_F(Name_Of_Specie='C', + Mass_Molaire=12.011, + Number_of_Particle=784,),), + List_Of_Bonded_Particles=_F(Bonded_Particles=(_F( + Name_Of_Bonded_Particles='C1', + Species_in_Particle=('C','C',),), + _F( + Name_Of_Bonded_Particles='C2', + Species_in_Particle=('C','C','C',),), + _F( + Name_Of_Bonded_Particles='C3', + Species_in_Particle=('C','C','C','C',),),),), + List_Of_Interactions=_F(Bonded_Interactions=(_F( + Type_Of_Bonded_Interaction='Covalent Bond Angle', + Interaction_Angles_Parameters=_F( + Apply_To_Bonded_Particles=('C3','C3',), + Spring_Stifness=1.0, + Mean_Bond_Angle=2.0,),), + _F( + Type_Of_Bonded_Interaction='Covalent Bond Length', + Interaction_Length_Parameters=_F( + Apply_To_Bonded_Particles=('C2',), + Spring_Stifness=3.0, + Mean_Bond_Length=4.0,),),), + Unbonded_Interactions=_F( + Type_Of_Unbonded_Interaction='Repulsion_and_VdW', + type_Repulsion_and_VdW='Lennard_Jones', + Species_Pair_Parameters=_F( + Species_Pair=('C','C',), + VdW_Radius=0.355, + Depth_Of_The_Potential_Well=0.292288,),), + External_Field_Interaction=_F( + Type_Of_Interaction_With_An_External_Field='No',),), + Statistical_Physics=_F(Type_Of_Statistical_Physics=\ + 'Equilibrium', + Distribution='nvt', + Target_Temperature=300.0,),), + Particle_Representation=_F(Representation_Type='Particle_Representation', + Type_Of_Entity='Atom', + Numerical_Particle_Model=_F(Type_Of_State_Vector='Kinetic',), + Definition_Numerical_Model=_F(Numerical_Model='MD', + Structure_Of_The_Evolution_Law=\ + 'Newton equations',),),), + Boundary_Conditions=_F(Type_Of_Boundary_Condition='Periodic', + Direction='XYZ',),); + +CodeSpecific(gen_vel=False, + Gromacs_Physical_Constraints=_F(Remove_Center_Of_Mass_Motion='Non Activ', + Bond_Constraints=_F(Bond_Constraint_Type='BC_none',), + Temperature_Coupling=_F(tcoupl='Non Activ',),), + Gromacs_Numerical_Description=_F(Integrator='steep', + emtol=10.0, + emstep=0.001, + Nb_Of_Steps=5000,), + Gromacs_Neighbor_Searching=_F(cutoff_scheme='group', + nstlist=10, + nst_type='grid', + periodic_molecules=True, + rlist=-1, + rcoulomb=1.0, + rvdw=1.0,), + Gromacs_Run_Options=_F(UserDef='-DFLEX_SRC', + Files_Energy_Minimization=_F(MDP_Initial_Input_File='/tmp/pp', + Gromos_File=\ + '/home/C65845/VIMMP/vimmp.training/app/gromacs/gromax.testdata/CNT53_12x057.gro', + Gromacs_Topology_File=\ + '/home/C65845/VIMMP/Salome_POLITO_gromacs/GROMACS/CNTconductivity_files/1-EM/TEST/CNT53_12x057.top', + MDP_File='em.mdp', + Run_Input_File='CNT53_12x057_em.trr', + log_File='/tmp/EM.log',),),); +#CHECKSUM:36af6eab259960058e9e5820059cf926 -:FIN CHECKSUM \ No newline at end of file -- 2.39.2