def compute_extrap(L, filling, bond_dim, correlation_type, at_x=None): ## Load all bond dimensions sets = map(lambda parms: to_dataset(*utils.load_or_evaluate('densdens', evaluate, **parms)), utils.iter_bond_dim(L=L, filling=filling, correlation_type=correlation_type)) sets = filter(lambda d: d.props is not None, sets) ## Extrapolate return extrapolate_local.extrapolate(sets, 'Density Correlation', foreach=['L', 't\'', 'Nup_total', 'Ndown_total'], extrap_type=bond_dim.type, deg=bond_dim.deg, num_points=bond_dim.num_points, full_output_at=[at_x])
def compute_extrap(L, filling, bond_dim): ## Load all bond dimensions sets = map(lambda parms: to_dataset(*utils.load_or_evaluate('energy', evaluate, **parms)), utils.iter_bond_dim(L=L, filling=filling)) sets = filter(lambda d: d.props is not None, sets) ## Extrapolate return extrapolate.extrapolate(sets, foreach=['L', 't\'', 'Nup_total', 'Ndown_total'], extrap_type=bond_dim.type, deg=bond_dim.deg, num_points=bond_dim.num_points)
def extrapolation(what, **kwargs): what = 'extrap_'+what fname = utils.filename(what, **kwargs) if path.exists(fname): return utils.load(fname) else: import pairfield_correlations, density_correlations, density, energy if what == 'extrap_pairfield': return utils.load_or_evaluate(what, pairfield_correlations.evaluate_extrap_at, **kwargs) elif what == 'extrap_densdens': return utils.load_or_evaluate(what, density_correlations.evaluate_extrap_at, **kwargs) elif what == 'extrap_density': return utils.load_or_evaluate(what, density.evaluate_extrap_at, **kwargs) elif what == 'extrap_energy': return utils.load_or_evaluate(what, energy.evaluate_extrap, **kwargs) else: raise Exception('`%s` is not a valid measurement.' % what)
def compute_fit(L, filling, bond_dim): ## Get data data = to_dataset(*utils.load_or_evaluate('density', evaluate, L=L, filling=filling, bond_dim=bond_dim)) if data.props is None: print 'Data not found for L={}, n={}, M={}'.format(L, filling, bond_dim) return data ## Compute fit d = dens_fit(data, fit_func(data.props['L'], data.props['nholes'])) return d
def result(what, **kwargs): fname = utils.filename(what, **kwargs) if path.exists(fname): return utils.load(fname) else: try: import pyalps_dset import pairfield_correlations, density_correlations, density, amplitudes if what == 'pairfield': return utils.load_or_evaluate(what, pairfield_correlations.evaluate, **kwargs) elif what == 'densdens': return utils.load_or_evaluate(what, density_correlations.evaluate, **kwargs) elif what == 'density': return utils.load_or_evaluate(what, density.evaluate, **kwargs) elif what == 'density_fit': return utils.load_or_evaluate(what, density.evaluate_fit, **kwargs) elif what == 'density_amplitudes': return utils.load_or_evaluate(what, amplitudes.evaluate, **kwargs) else: raise Exception('`%s` is not a valid measurement.' % what) except ImportError, e: print 'To execute new evaluations you need the ALPS.Python library.' print e
def compute_extrap(L, filling, bond_dim, correlation_type, at_x=None): ## Load all bond dimensions sets = map( lambda parms: to_dataset(*utils.load_or_evaluate("pairfield", evaluate, **parms)), utils.iter_bond_dim(L=L, filling=filling, correlation_type=correlation_type), ) sets = filter(lambda d: d.props is not None, sets) ## Extrapolate return extrapolate_local.extrapolate( sets, "Pairfield Correlation", foreach=["L", "t'", "Nup_total", "Ndown_total"], extrap_type=bond_dim.type, deg=bond_dim.deg, num_points=bond_dim.num_points, full_output_at=[at_x], )
def compute_extrap(L, filling, bond_dim, at_x=None): ## Load all bond dimensions sets = map(lambda parms: to_dataset(*utils.load_or_evaluate('density', evaluate, **parms)), utils.iter_bond_dim(L=L, filling=filling)) sets = filter(lambda d: d.props is not None, sets) # check that particle density in the middle is symmetric, otherwise exclude dataset # for L=192 it is better to use only M > 2000 def symm_middle_filter(d): x = int(d.props['L'] / 2) delta = abs(d.y[x] - d.y[x-1]) if d.props['L']%2==0 else abs(d.y[x+1] - d.y[x-1]) if delta > 5e-5: print '# Discard L={L:.0f}, n={filling}, tperp={t\'}, M={max_bond_dimension:.0f} : middle density not symmetry, delta={delta}'.format(delta=delta, **d.props) return False return True sets = filter(symm_middle_filter, sets) ## Extrapolate return extrapolate_local.extrapolate(sets, 'Rung density', foreach=['L', 't\'', 'Nup_total', 'Ndown_total'], extrap_type=bond_dim.type, deg=bond_dim.deg, num_points=bond_dim.num_points, full_output_at=[at_x])
def compute(filling, bond_dim, odd_sizes=False, amplitude_points=None): ## Load all system sizes if odd_sizes: densities = map(lambda parms: to_dataset(*utils.load_or_evaluate('density_fit', density.evaluate_fit, **parms)), utils.iter_odd_system_size(bond_dim=bond_dim, filling=filling)) else: densities = map(lambda parms: to_dataset(*utils.load_or_evaluate('density_fit', density.evaluate_fit, **parms)), utils.iter_system_size(bond_dim=bond_dim, filling=filling)) densities = filter(lambda d: d.props is not None, densities) if len(densities) < 3: print 'WARNING:', 'Only got {} valid densities, you need at least 3.'.format(len(densities)) d = pyalps_dset.DataSet() d.props = None return d # check that particle density in the middle is symmetric, otherwise exclude dataset # for L=192 it is better to use only M > 2000 # def symm_middle_filter(d): # x = int(d.props['L'] / 2) # delta = abs(d.y[x] - d.y[x-1]) if d.props['L']%2==0 else abs(d.y[x+1] - d.y[x-1]) # if delta > 5e-5: # print '# Discard L={L:.0f}, n={filling}, tperp={t\'}, M={max_bond_dimension:.0f} : {delta}'.format(delta=delta, **d.props) # return False # return True # densities = filter(symm_middle_filter, densities) ## Only even number of pairs densities = filter(lambda d: d.props['L']%2 != 0 or d.props['Nup_total'] % 2 == 0, densities) amplitudes = map(compute_amplitude, densities) for d in amplitudes: if d.props['density_fit_error'] > abs(d.y[0]): print 'WARNING:', 'Error in density fit is higher than amplitude magnitude.' print 'Error per site is', d.props['density_fit_error'], 'Amplidue is', d.y[0] print 'Dataset was:', 'L=%s filling=%s t_perp=%s M=%s' % (d.props['L'], d.props['filling'], d.props['t\''], d.props['max_bond_dimension']) common_props = pyalps_dset.dict_intersect([d.props for d in amplitudes]) amp_vs_L = pyalps_dset.collectXY(amplitudes, 'L', 'Amplitude') d = amp_vs_L[0] ## fit finite size analysis sel = np.ones(len(d.x), dtype=bool) if amplitude_points is not None and amplitude_points < len(d.x): sel[:-amplitude_points] = False cov = np.ones((2,2))*np.nan if sum(sel) > 2: coeff, cov = np.polyfit(np.log(d.x[sel]), np.log(d.y[sel]), deg=1, cov=True) else: coeff = np.polyfit(np.log(d.x[sel]), np.log(d.y[sel]), deg=1) r2 = rsquared(np.log(d.x), np.log(d.y), coeff) fit_range = [d.x[0], d.x[-1]] if amplitude_points is not None and amplitude_points < len(d.x): fit_range[0] = d.x[-amplitude_points] ## compute new Krho slope = coeff[0] errslope = np.sqrt(cov[0,0]) Krho = -2. * slope errKrho = 2. * errslope print 'M={} t_perp={} filling={:4.4f} -> Krho={:.3f} +/- {:.3f} : R^2 {:.4f}'.format(common_props['max_bond_dimension'], common_props['t\''], common_props['filling'], Krho, errKrho, r2) d.props['fit_range'] = fit_range d.props['fit_numpoints'] = amplitude_points d.props['fitted_coeff'] = coeff d.props['fitted_Krho'] = Krho d.props['fitted_Krho_error'] = errKrho d.props['fitted_r2'] = r2 return d