def add_neuroml_components(self, nml_doc):
        """
            Based on cell & synapse properties found, create the corresponding NeuroML components
        """
        
        is_nest = False
        print_v("Adding NeuroML cells to: %s"%nml_doc.id)
        #pp.pprint(self.pop_comp_info)
        
        for c in self.pop_comp_info:
            info = self.pop_comp_info[c]
            
            model_template = info['model_template'] if 'model_template' in info else \
                             (info['dynamics_params']['type'] if 'dynamics_params' in info else
                             info['model_type'])
            
            print_v(" - Adding %s: %s"%(model_template, info))
            
            if info['model_type'] == 'point_process' and model_template == 'nest:iaf_psc_alpha':
                
                is_nest = True
                from neuroml import IF_curr_alpha
                pynn0 = IF_curr_alpha(id=c, 
                                      cm=info['dynamics_params']['C_m']/1000.0, 
                                      i_offset="0", 
                                      tau_m=info['dynamics_params']['tau_m'], 
                                      tau_refrac=info['dynamics_params']['t_ref'], 
                                      tau_syn_E="1", 
                                      tau_syn_I="1", 
                                      v_init='-70', 
                                      v_reset=info['dynamics_params']['V_reset'], 
                                      v_rest=info['dynamics_params']['E_L'], 
                                      v_thresh=info['dynamics_params']['V_th'])
                                      
                nml_doc.IF_curr_alpha.append(pynn0)
                
            elif info['model_type'] == 'point_process' and model_template == 'NEURON_IntFire1':
                
                contents = '''<Lems>
    <intFire1Cell id="%s" thresh="1mV" reset="0mV" tau="%sms" refract="%sms"/>
</Lems>'''%(c, info['dynamics_params']['tau']*1000, info['dynamics_params']['refrac']*1000)

                cell_file_name = '%s.xml'%c
                cell_file = open(cell_file_name,'w')
                cell_file.write(contents)
                cell_file.close()
                
                self.nml_includes.append(cell_file_name)
                self.nml_includes.append('../../../examples/sonatatest/IntFireCells.xml')
                
                
            else:
                
                from neuroml import IafRefCell
                IafRefCell0 = IafRefCell(id=DUMMY_CELL,
                           C=".2 nF",
                           thresh = "1mV",
                           reset="0mV",
                           refract="3ms",
                           leak_conductance="1.2 nS",
                           leak_reversal="0mV")

                print_v("   - Adding: %s"%IafRefCell0)
                nml_doc.iaf_ref_cells.append(IafRefCell0)
                
        print_v("Adding NeuroML synapses to: %s"%nml_doc.id)
        
        #pp.pprint(self.syn_comp_info)
        
        for s in self.syn_comp_info:
            dyn_params = self.syn_comp_info[s]['dynamics_params']
            
            print_v("     -  Syn: %s: %s"%(s, dyn_params))
            
            if 'level_of_detail' in dyn_params and dyn_params['level_of_detail'] == 'exp2syn':
                from neuroml import ExpTwoSynapse

                syn = ExpTwoSynapse(id=s, 
                                    gbase="1nS",
                                    erev="%smV"%dyn_params['erev'],
                                    tau_rise="%sms"%dyn_params['tau1'],
                                    tau_decay="%sms"%dyn_params['tau2'])
                                    
                #print("Adding syn: %s"%syn)
                nml_doc.exp_two_synapses.append(syn)
                
            elif 'level_of_detail' in dyn_params and dyn_params['level_of_detail'] == 'instanteneous':
                
                contents = '''<Lems>
    <impulseSynapse id="%s"/>
</Lems>'''%(s)

                syn_file_name = '%s.xml'%s
                syn_file = open(syn_file_name,'w')
                syn_file.write(contents)
                syn_file.close()
                
                self.nml_includes.append(syn_file_name)
                #self.nml_includes.append('../examples/sonatatest/IntFireCells.xml')
                
            else:
                from neuroml import AlphaCurrSynapse
                pynnSynn0 = AlphaCurrSynapse(id=s, tau_syn="2")
                #print("Adding syn: %s"%pynnSynn0)
                nml_doc.alpha_curr_synapses.append(pynnSynn0)
            
                
        print_v("Adding NeuroML inputs to: %s"%nml_doc.id)
                
        #pp.pprint(self.input_comp_info)
        
        for input in self.input_comp_info:
            for input_type in self.input_comp_info[input]:
                if input_type == 'spikes':
                    for comp_id in self.input_comp_info[input][input_type]:
                        info = self.input_comp_info[input][input_type][comp_id]
                        print_v("Adding input %s: %s"%(comp_id, info.keys()))
                        
                        nest_syn = _get_default_nest_syn(nml_doc)
                        from neuroml import TimedSynapticInput, Spike

                        tsi = TimedSynapticInput(id=comp_id, synapse=nest_syn.id, spike_target="./%s"%nest_syn.id)
                        nml_doc.timed_synaptic_inputs.append(tsi)
                        for ti in range(len(info['times'])):
                            tsi.spikes.append(Spike(id=ti, time='%sms'%info['times'][ti]))
                elif input_type == 'current_clamp':
                    from neuroml import PulseGenerator
                    for comp_id in self.input_comp_info[input][input_type]:
                        info = self.input_comp_info[input][input_type][comp_id]
                        #TODO remove when https://github.com/AllenInstitute/sonata/issues/42 is fixed!
                        amp_template = '%spA' if is_nest else '%snA' # 
                        pg = PulseGenerator(id=comp_id,delay='%sms'%info['delay'],duration='%sms'%info['duration'],amplitude=amp_template%info['amp'])
                        nml_doc.pulse_generators.append(pg)