Timer unit: 1e-06 s Total time: 232.892 s File: /pfs/work/g2pbloch/jetto_profiler/jintrac_imas_driver.py Function: jintrac_imas_driver at line 721 Line # Hits Time Per Hit % Time Line Contents ============================================================== 721 @profile 722 def jintrac_imas_driver(params, components, mpi='no'): 723 724 """JINTRAC-IMAS generic workflow driver.""" 725 726 # Workflow configuration parameters 727 728 1 5.9 5.9 0.0 user_in = wf.string(params, "Input IDS user") 729 1 2.3 2.3 0.0 machine_in = wf.string(params, "Input IDS machine") 730 1 4.7 4.7 0.0 shot_in = wf.integer(params, "Input IDS shot") 731 1 2.1 2.1 0.0 run_in = wf.integer(params, "Input IDS run") 732 1 2.9 2.9 0.0 user_out = wf.string(params, "Output IDS user") 733 1 2.6 2.6 0.0 machine_out = wf.string(params, "Output IDS machine") 734 1 2.6 2.6 0.0 shot_out = wf.integer(params, "Output IDS shot") 735 1 2.6 2.6 0.0 run_out = wf.integer(params, "Output IDS run") 736 1 13.3 13.3 0.0 user_tmp = os.environ['HOME']+'/public/tempdb' 737 738 1 7.9 7.9 0.0 tstart = wf.real(params, "Start time") 739 1 4.6 4.6 0.0 tend = wf.real(params, "End time") 740 1 4.1 4.1 0.0 noprocessors = wf.integer(params, "Number of processors for parallelised actors") 741 1 3.5 3.5 0.0 lreplace = (wf.integer(params, "Replace existing IDS") == 1) 742 743 1 0.5 0.5 0.0 if mpi == 'yes': 744 1 281521.5 281521.5 0.1 from mpi4py import MPI # This import performs an implicit MPI_INIT 745 1 1.7 1.7 0.0 mpicfg.init = True 746 1 1.4 1.4 0.0 mpicfg.comm = MPI.COMM_WORLD 747 1 4.0 4.0 0.0 mpicfg.size = mpicfg.comm.Get_size() 748 1 3.1 3.1 0.0 mpicfg.rank = mpicfg.comm.Get_rank() 749 1 4.5 4.5 0.0 mpicfg.myrank = "(MPI process "+str(mpicfg.rank)+")" 750 1 0.9 0.9 0.0 mpi_root = (mpicfg.rank == 0) 751 1 1.0 1.0 0.0 if mpi_root: 752 1 1.4 1.4 0.0 if mpicfg.size == 1: 753 1 54.5 54.5 0.0 print("JINTRAC_IMAS_DRIVER: Parallel MPI execution (1 process)") 754 else: 755 print("JINTRAC_IMAS_DRIVER: Parallel MPI execution ({0} processes)".format(mpicfg.size)) 756 else: 757 print("JINTRAC_IMAS_DRIVER: Serial execution (no MPI)") 758 noprocessors = 1 759 mpi_root = True 760 761 1 0.7 0.7 0.0 if mpi_root: 762 1 6.7 6.7 0.0 print("") 763 1 22.4 22.4 0.0 print("JINTRAC_IMAS_DRIVER: Workflow configuration parameters") 764 1 37.2 37.2 0.0 print("JINTRAC_IMAS_DRIVER: tstart =", tstart) 765 1 15.1 15.1 0.0 print("JINTRAC_IMAS_DRIVER: tend =", tend) 766 1 22.2 22.2 0.0 print("JINTRAC_IMAS_DRIVER: shot,run(in) =", shot_in, run_in) 767 1 12.9 12.9 0.0 print("JINTRAC_IMAS_DRIVER: machine(in) =", machine_in) 768 1 14.4 14.4 0.0 print("JINTRAC_IMAS_DRIVER: user(in) =", user_in) 769 1 19.2 19.2 0.0 print("JINTRAC_IMAS_DRIVER: shot,run(out) =", shot_out, run_out) 770 1 13.7 13.7 0.0 print("JINTRAC_IMAS_DRIVER: machine(out) =", machine_out) 771 1 12.2 12.2 0.0 print("JINTRAC_IMAS_DRIVER: user(out) =", user_out) 772 1 15.2 15.2 0.0 print("JINTRAC_IMAS_DRIVER: no. processors =", noprocessors) 773 1 14.6 14.6 0.0 print("JINTRAC_IMAS_DRIVER: replace IDS =", lreplace) 774 775 1 17.7 17.7 0.0 print("\nActive Components:", components) 776 777 1 0.4 0.4 0.0 comment_file = 'ids_comment' 778 779 1 33.8 33.8 0.0 imas_control = WorkflowControl() 780 1 2.8 2.8 0.0 num_components = imas_control.get_num_components() 781 782 # Build list of components to be used 783 1 0.7 0.7 0.0 component_list = [] # component_list is identical to components but with upper case enforcement 784 3 1.1 0.4 0.0 for item in components: 785 3 3.3 1.1 0.0 component_list.append(item.upper()) 786 787 # Reference Python actors as global functions 788 1 0.5 0.5 0.0 list_of_jintrac_actors = ['edge2d', 'jetto', 'coconut'] 789 1 8.4 8.4 0.0 for name in [name for name in list_of_jintrac_actors if name.upper() in component_list]: 790 1 0.3 0.3 0.0 try: 791 1 127399.4 127399.4 0.1 import_actor(name) 792 except: 793 error_exit("JINTRAC_IMAS_DRIVER: Reference to JINTRAC Python actor ", name.upper(), " not found!") 794 795 1 1.4 1.4 0.0 if 'HCD' in component_list: 796 try: 797 globals()['hcd_jintrac_interface'] = getattr(import_module('hcd_jintrac_interface'), 'hcd_jintrac_interface') 798 globals()['hcd_jintrac_interface_init'] = getattr(import_module('hcd_jintrac_interface'), 'hcd_jintrac_interface_init') 799 except: 800 error_exit("JINTRAC_IMAS_DRIVER: Reference to HCD JINTRAC plugin interface routines not found!") 801 802 # Make list of input and output IDS objects 803 # from combined lists of required IDS structures for each workflow component 804 1 0.2 0.2 0.0 ids_list = [] 805 3 0.9 0.3 0.0 for elem in component_list: 806 3 6.9 2.3 0.0 ids_list.extend(imas_control.get_ids_list_required(elem)) 807 1 4.5 4.5 0.0 ids_list = list(set(ids_list)) # Remove duplicates 808 809 # Determine IMAS backend 810 1 9.4 9.4 0.0 backendtype = os.environ['JINTRAC_IMAS_BACKEND'] 811 1 0.7 0.7 0.0 if backendtype == None: 812 if mpi_root: print("JINTRAC_IMAS_DRIVER: No IMAS IDS backend ($JINTRAC_IMAS_BACKEND) selected, using MDSPLUS.") 813 backendtype = 'MDSPLUS' 814 1 0.5 0.5 0.0 if backendtype == 'MDSPLUS': 815 # previous IDS data access scheme in use with MDSPLUS backend selection 816 # for backwards compatibility while IMAS versions < 3.35 are still in use on some clusters 817 1 1.6 1.6 0.0 backend = imas.imasdef.MDSPLUS_BACKEND 818 elif backendtype == 'HDF5': 819 backend = imas.imasdef.HDF5_BACKEND 820 else: 821 error_exit("JINTRAC_IMAS_DRIVER: Selected IMAS IDS backend ($JINTRAC_IMAS_BACKEND=" 822 +backendtype+") not supported!") 823 824 # Open/create output local datafile 825 1 3.3 3.3 0.0 version = os.environ['IMAS_VERSION'][:1] 826 1 0.4 0.4 0.0 if mpi_root: 827 1 26.4 26.4 0.0 print("Creating local database "+user_out+'/'+machine_out+'/'+version) 828 1 0.6 0.6 0.0 if user_out[0] != '/': 829 user_out_root = os.environ['HOME']+'/public/imasdb' 830 else: 831 1 0.3 0.3 0.0 user_out_root = user_out 832 1 12.6 12.6 0.0 if not os.path.exists(user_out_root+'/'+machine_out+'/'+version): 833 os.makedirs(user_out_root+'/'+machine_out+'/'+version) 834 1 0.5 0.5 0.0 if backendtype == 'MDSPLUS': 835 1 0.3 0.3 0.0 if user_out[0] != '/': 836 os.popen("imasdb "+machine_out).read() 837 else: 838 1 32981.5 32981.5 0.0 os.popen("imasdb "+user_out_root+'/'+machine_out+'/'+version).read() 839 elif backendtype == 'HDF5': 840 hdf5_outdir = user_out_root+'/'+machine_out+'/'+version+'/'+str(shot_out) 841 if not os.path.exists(hdf5_outdir): 842 os.mkdir(hdf5_outdir) 843 844 1 2.2 2.2 0.0 if mpicfg.init and mpicfg.size > 1: mpicfg.comm.barrier() 845 846 1 0.5 0.5 0.0 idx_out = -9999 847 1 1.6 1.6 0.0 if 'IDSOUT' in component_list: 848 1 23.6 23.6 0.0 if mpi_root: print("Initialising output IDS...") 849 1 27.3 27.3 0.0 DBentry.idsout = imas.DBEntry(backend, machine_out, shot_out, run_out, user_name=user_out) 850 851 1 0.4 0.4 0.0 create_ids = lreplace 852 1 0.6 0.6 0.0 if create_ids == False: 853 if mpi_root: print("...Opening output IDS environment...", user_out, machine_out, version) 854 status, idx_out = DBentry.idsout.open() # idx_out points to output IDS file index 855 if status != 0: 856 if mpi_root: print("IDS output file does not exist; creating new file instead...") 857 create_ids = True 858 859 1 0.3 0.3 0.0 if create_ids: 860 1 0.3 0.3 0.0 if mpi_root: 861 1 499.3 499.3 0.0 print("...Creating output IDS environment...", user_out, machine_out, version) 862 1 436811.4 436811.4 0.2 status, idx_out = DBentry.idsout.create() # idx_out points to output IDS file index 863 1 5.1 5.1 0.0 if status != 0: 864 error_exit("IDS output file creation has failed... Aborting with status = "+str(status)) 865 866 1 9.5 9.5 0.0 if mpicfg.init and mpicfg.size > 1: 867 idx_out = mpicfg.comm.bcast(idx_out, root=0) 868 869 # Open input datafile; shot_in=0 indicates no IDS inputs 870 1 23979.0 23979.0 0.0 ids_in = imas.ids(0, 0, 0, 0) 871 1 0.6 0.6 0.0 idx_in = -9999 872 1 1.7 1.7 0.0 if shot_in == 0: 873 if 'IDSOUT' in component_list: 874 idx_in = idx_out 875 if DBentry.API == 'NEW': 876 DBentry.idsin = DBentry.idsout 877 else: 878 # Set up dummy input IDS file (required for input slice initialisation) 879 if DBentry.API == 'NEW': 880 DBentry.idsin = imas.DBEntry(backend, '', 0, 0) 881 else: 882 1 37.4 37.4 0.0 if mpi_root: print("Opening input IDS...") 883 1 1.6 1.6 0.0 if DBentry.API == 'OLD': 884 ids_in = imas.ids(shot_in, run_in) 885 ids_in.open_env(user_in, machine_in, version) 886 idx_in = ids_in.core_profiles.getPulseCtx() # idx_in points to input IDS file index 887 else: 888 1 35.1 35.1 0.0 DBentry.idsin = imas.DBEntry(backend, machine_in, shot_in, run_in, user_name=user_in) 889 1 1026.5 1026.5 0.0 status, idx_in = DBentry.idsin.open() # idx_in points to input IDS file index 890 1 1.4 1.4 0.0 if status != 0: 891 error_exit("Failure to open input IDS file... Aborting with status = "+str(status)) 892 893 # Initialise temporary IDS file 894 # Required by all workflows calling physics actors - see JIRA issue IMAS-2921 895 1 62545203.7 62545203.7 26.9 alenv = ALEnv(user_temp=user_tmp) 896 1 11.2 11.2 0.0 tmp_db = alenv.ids_tmp 897 898 # Set up IDS bundles, to make it easier to pass the IDSs between actors 899 # ids_bundle_input: IDS time slice from input database file, used i.a. for initialisation 900 # ids_bundle_work: input IDSs of the current timestep, only one timeslice 901 # ids_bundle_prev: collection of component-specific output IDSs from the previous component call 902 # (initialised by subset of ids_bundle_work), only one timeslice 903 # ids_bundle_updated: output IDSs of the current timestep, only one timeslice 904 905 # Initial IDS bundle (must contain all IDSs likely to be used) 906 # Unused IDSs are removed from this list below 907 1 11.8 11.8 0.0 ids_list_complete = imas_control.get_complete_ids_list() 908 1 1.2 1.2 0.0 ids_bundle_input = {} 909 22 15.5 0.7 0.0 for ids_struct in ids_list_complete: 910 22 32.9 1.5 0.0 if DBentry.API == 'OLD': 911 ids_bundle_input[ids_struct] = eval('ids_in.'+ids_struct) 912 else: 913 22 5.8 0.3 0.0 try: 914 # Next line currently causes problems if: 915 # - no IDSIN is required (i.e. shot_in==0), AND 916 # - IDSOUT datafile does not yet exist 917 22 49496025.7 2249819.4 21.3 ids_bundle_input[ids_struct] = eval('DBentry.idsin.get("'+ids_struct+'")') 918 except: 919 # Fall-back to using old-style API call to define structure 920 ids_bundle_input[ids_struct] = eval('ids_in.'+ids_struct) 921 922 1 83745046.9 83745046.9 36.0 tmpdict = bundle_copy(ids_bundle_input) 923 22 11.4 0.5 0.0 for elem in tmpdict: 924 12 10.6 0.9 0.0 if elem not in ids_list: 925 10 726.0 72.6 0.0 del ids_bundle_input[elem] 926 else: 927 12 6.5 0.5 0.0 if shot_in != 0: 928 12 11.6 1.0 0.0 if DBentry.API == 'OLD': 929 ids_bundle_input[elem].ids_properties.homogeneous_time = ids_bundle_input[elem].getField('ids_properties/homogeneous_time') 930 else: 931 12 22974.7 1914.6 0.0 ids_bundle_input[elem].ids_properties.homogeneous_time = DBentry.idsin.get_node(elem, 'ids_properties/homogeneous_time') 932 933 # Read in input IDS data, if present 934 1 0.6 0.6 0.0 if shot_in != 0: 935 1 29.4 29.4 0.0 if mpi_root: print("Reading input IDS...") 936 12 11.8 1.0 0.0 for elem in ids_bundle_input: 937 8 63.0 7.9 0.0 if is_populated(ids_bundle_input[elem],1): 938 4 13006.8 3251.7 0.0 if mpi_root: print("Getting first slice from ", elem, "...") 939 3 3.6 1.2 0.0 if elem != 'equilibrium' and elem != 'summary' and elem != 'core_sources' and elem != 'workflow' and elem != 'pulse_schedule': 940 1 0.7 0.7 0.0 if DBentry.API == 'OLD': 941 ids_bundle_input[elem].getSlice(tstart, 3) 942 else: 943 1 743832.2 743832.2 0.3 ids_bundle_input[elem] = DBentry.idsin.get_slice(elem, tstart, 3) 944 3 2.9 1.0 0.0 elif elem == 'summary' or elem == 'workflow': # getSlice procedure does not work for summary IDS in test case #130011/public/iter/1 as array heating_current_drive.nbi[0].power.values does not seem to be populated 945 ids_bundle_input[elem].ids_properties.homogeneous_time = imas.imasdef.IDS_TIME_MODE_HOMOGENEOUS # set homogeneous time flag and add dummy time as empty IDS structures cannot be passed as argument to Python actors with IMAS version >= 3.28.0 even if they are not used by the actors 946 ids_bundle_input[elem].time = np.array([-9999.0]) 947 2 2.0 1.0 0.0 elif elem == 'pulse_schedule': 948 1 1.8 1.8 0.0 if DBentry.API == 'OLD': 949 ids_bundle_input[elem].get() 950 else: 951 1 1969320.6 1969320.6 0.8 ids_bundle_input[elem] = DBentry.idsin.get(elem) 952 else: # getSlice interpolation option does not seem to work for equilibrium IDS in test case #130011/public/iter/1 (segmentation fault for unknown reasons); core_sources contains time slice for t = 1.5 s three times, once at the beginning and two times at the end of the times array; core_sources contains two sources with the same identifier 'ec'; names and indices for core_sources source identifiers are not in agreement with name-index association given in the data dictionary 953 2 5.2 2.6 0.0 if DBentry.API == 'OLD': 954 ids_bundle_input[elem].getSlice(tstart, 3) 955 else: 956 2 4665617.1 2332808.6 2.0 ids_bundle_input[elem] = DBentry.idsin.get_slice(elem, tstart, 3) 957 else: # set homogeneous time flag and add dummy time as empty IDS structures cannot be passed as argument to Python actors with IMAS version >= 3.28.0 even if they are not used by the actors 958 8 10.1 1.3 0.0 ids_bundle_input[elem].ids_properties.homogeneous_time = imas.imasdef.IDS_TIME_MODE_HOMOGENEOUS 959 8 54.5 6.8 0.0 ids_bundle_input[elem].time = np.array([-9999.0]) 960 else: 961 for elem in ids_bundle_input: 962 ids_bundle_input[elem].ids_properties.homogeneous_time = imas.imasdef.IDS_TIME_MODE_HOMOGENEOUS 963 ids_bundle_input[elem].time = np.array([-9999.0]) 964 965 # Copy slice from ids_bundle_input to ids_bundle_work and ids_bundle_updated 966 1 6353190.5 6353190.5 2.7 ids_bundle_work = bundle_copy(ids_bundle_input) 967 1 7884627.8 7884627.8 3.4 ids_bundle_updated = bundle_copy(ids_bundle_input) 968 969 # Set up initial workflow IDS, turn on required components and set initial time intervals 970 # Trigger first component only 971 1 13.4 13.4 0.0 ids_bundle_work['workflow'].time = np.array([tstart]) 972 1 56.6 56.6 0.0 ids_bundle_work['workflow'].time_loop.component.resize(num_components) 973 1 23.3 23.3 0.0 ids_bundle_work['workflow'].time_loop.workflow_cycle.resize(1) 974 1 94.0 94.0 0.0 ids_bundle_work['workflow'].time_loop.workflow_cycle[0].component.resize(num_components) 975 1 11.1 11.1 0.0 names = imas_control.get_array_order() 976 8 2.8 0.4 0.0 for icomponent in range(num_components): 977 8 9.4 1.2 0.0 ids_bundle_work['workflow'].time_loop.component[icomponent].name = names[icomponent] 978 8 11.2 1.4 0.0 ids_bundle_work['workflow'].time_loop.workflow_cycle[0].component[icomponent].index = icomponent + 1 #index in Fortran notation 979 8 9.4 1.2 0.0 ids_bundle_work['workflow'].time_loop.workflow_cycle[0].component[icomponent].execution_mode = 0 980 8 9.4 1.2 0.0 ids_bundle_work['workflow'].time_loop.workflow_cycle[0].component[icomponent].time_interval = 0.0 981 8 21.7 2.7 0.0 ids_bundle_work['workflow'].time_loop.workflow_cycle[0].component[icomponent].control_integer = np.array([0, 0, 0, 0]) 982 8 16.3 2.0 0.0 ids_bundle_work['workflow'].time_loop.workflow_cycle[0].component[icomponent].control_float = np.array([0.0]) 983 3 1.1 0.4 0.0 for icomponent in component_list: 984 3 4.4 1.5 0.0 icomponent_index = imas_control.get_component_index(icomponent) 985 3 4.5 1.5 0.0 ids_bundle_work['workflow'].time_loop.workflow_cycle[0].component[icomponent_index].time_interval = tend-tstart 986 1 1.1 1.1 0.0 ids_bundle_work['workflow'].time_loop.time_end = tend 987 1 0.9 0.9 0.0 first_component_index = imas_control.get_component_index(component_list[0]) 988 1 1.2 1.2 0.0 ids_bundle_work['workflow'].time_loop.workflow_cycle[0].component[first_component_index].execution_mode = 1 989 # Always set JETTO trigger, required for decomposed COCONUT runs: 990 1 0.7 0.7 0.0 if 'JETTO' in component_list: 991 1 0.9 0.9 0.0 jetto_component_index = imas_control.get_component_index('JETTO') 992 1 1.3 1.3 0.0 ids_bundle_work['workflow'].time_loop.workflow_cycle[0].component[jetto_component_index].execution_mode = 1 993 1 0.4 0.4 0.0 if 'IDSIN' in component_list: 994 1 0.8 0.8 0.0 idsin_component_index = imas_control.get_component_index('IDSIN') 995 1 3.3 3.3 0.0 ids_bundle_work['workflow'].time_loop.workflow_cycle[0].component[idsin_component_index].control_integer[2] = idx_in 996 1 0.5 0.5 0.0 if 'IDSOUT' in component_list: 997 1 0.9 0.9 0.0 idsout_component_index = imas_control.get_component_index('IDSOUT') 998 1 1.4 1.4 0.0 ids_bundle_work['workflow'].time_loop.workflow_cycle[0].component[idsout_component_index].control_integer[2] = idx_out 999 1 0.4 0.4 0.0 if create_ids == False: 1000 # Do not recreate IDS datafile if it exists already in case of restart from IMAS case; 1001 # instead, append to the existing IDS datafile, assuming that put() procedure has already been run 1002 # for each IDS structure in the preceding run. This assumption may need to be revised later on! 1003 for elem in ids_list: 1004 elemidx = imas_control.get_idsname_index(elem) 1005 ids_bundle_work['workflow'].time_loop.workflow_cycle[0].component[idsout_component_index].control_integer[3] += 2**(elemidx) 1006 1007 # Zero HCD sources as they may be supposed to be provided from external actor that has not yet been called 1008 # (this part can be removed pending adaptations in JINTRAC for non-consideration of external source input 1009 # at (non-restart) initialisation step if HCD workflow is active and sources are not supposed to come from input IDS files): 1010 # TEMPORARILY(?) COMMENTED-OUT, BECAUSE IF THIS IS EXECUTED WITH AN EDGE2D-ONLY RUN WE GET A 1011 # KeyError('core_sources') EXCEPTION FOR REASONS NOT CLEAR TO ME (PJK) - IF ANYONE CAN EXPLAIN, PLEASE... 1012 #for isource in range(len(ids_bundle_work['core_sources'].source)): 1013 # ids_bundle_work['core_sources'].source[isource].profiles_1d[0].electrons.energy[:] = 0.0 1014 # ids_bundle_work['core_sources'].source[isource].profiles_1d[0].total_ion_energy[:] = 0.0 1015 # ids_bundle_work['core_sources'].source[isource].profiles_1d[0].j_parallel[:] = 0.0 1016 # for iion in range(len(ids_bundle_work['core_sources'].source[isource].profiles_1d[0].ion)): 1017 # ids_bundle_work['core_sources'].source[isource].profiles_1d[0].ion[iion].particles[:] = 0.0 1018 # ids_bundle_work['core_sources'].source[isource].profiles_1d[0].momentum_tor[:] = 0.0 1019 1020 1 0.2 0.2 0.0 ids_bundle_prev = {} 1021 3 2.0 0.7 0.0 for item in component_list: 1022 3 14539266.0 4846422.0 6.2 ids_bundle_prev[item] = bundle_copy(ids_bundle_work,imas_control.get_ids_sublist_updates(item)) 1023 1024 1 1.5 1.5 0.0 if 'IDSOUT' in component_list: 1025 1 31.1 31.1 0.0 if mpi_root: print("Writing dataset_description") 1026 1 9.6 9.6 0.0 ids_bundle_updated['dataset_description'] \ 1027 1 848.4 848.4 0.0 = dd.init(ids_bundle_work['dataset_description'], 0, 1028 1 0.2 0.2 0.0 comment_file) 1029 1 20.6 20.6 0.0 ids_bundle_updated['dataset_description'].setPulseCtx(idx_out) 1030 1 0.3 0.3 0.0 if mpi_root: 1031 1 3919.6 3919.6 0.0 DBentry.idsout.put(ids_bundle_updated['dataset_description']) 1032 #code.interact(local=locals()) 1033 1034 # Time loop 1035 1036 1 0.6 0.6 0.0 time = tstart 1037 1 0.4 0.4 0.0 while time < tend: 1038 1 285.2 285.2 0.0 print("time =", time, '\n') 1039 8 5.8 0.7 0.0 for icomponent in range(num_components): 1040 8 20.7 2.6 0.0 ids_bundle_work['workflow'].time[0] = time 1041 8 23.4 2.9 0.0 ids_bundle_work['workflow'].time_loop.workflow_cycle[0].component[icomponent].control_integer[0] = 0 #re-set action flag 1042 8 29.6 3.7 0.0 ids_bundle_work['workflow'].time_loop.workflow_cycle[0].component[icomponent].control_float = np.array([0.0]) 1043 1 1739.3 1739.3 0.0 ids_bundle_updated['workflow'].copyValues(ids_bundle_work['workflow']) #workflow IDS from ids_bundle_updated foreseen to be used by all actors 1044 1045 # Advance each component 1046 1 0.5 0.5 0.0 for item in component_list: 1047 1 206.1 206.1 0.0 print("check trigger for item ",item,"...") 1048 1 3.5 3.5 0.0 item_index = imas_control.get_component_index(item) 1049 1 2.5 2.5 0.0 if ids_bundle_updated['workflow'].time_loop.workflow_cycle[0].component[item_index].execution_mode == 1: 1050 1 53.7 53.7 0.0 print("wrapper called for item ",item,"...") 1051 1 0.3 0.3 0.0 args = ("(noprocessors, imas_control, ids_bundle_updated, ids_bundle_work, ids_bundle_prev[item])") 1052 1053 # Call component via its wrapper 1054 1 113.3 113.3 0.0 ids_bundle_updated_tmp = eval(imas_control.get_wrapper(item) + args) 1055 1056 # Workflow-component specific consideration of IDS updates, update ids_bundle_prev: 1057 for ids_struct in imas_control.get_ids_sublist_updates(item): 1058 if ids_struct in ids_bundle_updated_tmp: 1059 if is_populated(ids_bundle_updated_tmp[ids_struct],2): 1060 ids_bundle_updated[ids_struct].copyValues(ids_bundle_updated_tmp[ids_struct]) 1061 ids_bundle_prev[item][ids_struct].copyValues(ids_bundle_updated_tmp[ids_struct]) 1062 elif ids_struct == 'transport_solver_numerics': 1063 if is_populated(ids_bundle_updated_tmp[ids_struct],1): 1064 ids_bundle_updated[ids_struct].copyValues(ids_bundle_updated_tmp[ids_struct]) 1065 ids_bundle_prev[item][ids_struct].copyValues(ids_bundle_updated_tmp[ids_struct]) 1066 1067 # Copy newly updated IDS into input (work) IDS, 1068 # ready for next time step 1069 ids_bundle_work = bundle_copy(ids_bundle_updated) 1070 1071 # Update and increment time 1072 time = ids_bundle_work['workflow'].time[0] 1073 dtmax = 0.0 1074 for icomponent in component_list: 1075 icomponent_index = imas_control.get_component_index(icomponent) 1076 dtmax = max(dtmax, ids_bundle_work['workflow'].time_loop.workflow_cycle[0].component[icomponent_index].time_interval) 1077 time += dtmax 1078 print("Calculated time interval = ", dtmax) 1079 dtmaxnew = tend-time 1080 for icomponent in component_list: 1081 icomponent_index = imas_control.get_component_index(icomponent) 1082 ids_bundle_work['workflow'].time_loop.workflow_cycle[0].component[icomponent_index].time_interval = dtmaxnew 1083 print("Next target interval = ", dtmaxnew) 1084 1085 # end of time loop 1086 1087 print("Finish time =", time) 1088 1089 alenv.close() 1090 1091 ids_in.close() 1092 if DBentry.API == 'NEW': 1093 DBentry.idsin.close() 1094 1095 if 'IDSOUT' in component_list: 1096 DBentry.idsout.close() 1097 1098 return 0