Dear Professor Todo, Sorry to bother you again. I have seen the spinsim.h file, which is very hard for me to understand the codes without detailed comments. Yesterday, I added the following code into the do_measurements function of spinsim.h: ``` if (M::dim == 2) { typename parent::site_iterator si; si=this->sites().first; double m_x = 0.; double m_y = 0.; m_x = this->spinfactor_[*si]*spins_[*si].mag_h({1.,0.}); m_y = this->spinfactor_[*si]*spins_[*si].mag_h({0.,1.}); ++si; for (; si !=this->sites().second ; ++si) { m_x += this->spinfactor_[*si]*spins_[*si].mag_h({1.,0.}); m_y += this->spinfactor_[*si]*spins_[*si].mag_h({0.,1.}); } double mx=m_x/this->num_sites(); double my=m_y/this->num_sites(); this->measurements.template get<alps::RealObservable>("Magnetization along x-axis") << mx; this->measurements.template get<alps::RealObservable>("Magnetization along y-axis") << my; } ``` I am still confused about how you perform the iteration of sites, so I just repeated what you have done for m, m_h and mst. Then I recompiled the spinmc, and it did give me some results. I just want to ask if is it correct to use .mag_h({1.,0.}) and .mag_h({0.,1.}) to get M_x and M_y? Or is there a better way? Thank you, Wei On Oct 13, 2020, at 21:38, Synge Todo <wistaria@phys.s.u-tokyo.ac.jp<mailto:wistaria@phys.s.u-tokyo.ac.jp>> wrote: Dear Wei, As for <M_x^2>, it should be given by "Magnetization^2" divided by 2, as < Magnetization^2> = <M_x^2> + <M_y^2> = <M_x^2> / 2 for the XY model. As far as I know, <N_x>=<\cos 2\theta> is not implemented in the current version of spinmc. You have to write the code somewhere in applications/mc/spins/spinsim.h by your self. But, it should be straightforward. Best, Synge On Oct 12, 2020, at 11:20, Wei Wang <wei.wang@jhu.edu<mailto:wei.wang@jhu.edu>> wrote: Hi Professor Todo, Sorry to bother you again. But what if I want to measure <M_x^2>=<\cos^2\theta> or the nematic <N_x>=<\cos 2\theta> of XY model by ALPS? I have googled it but didn't find anything related. Could you kindly give me some suggestions? Or I need to modify the source code of ALPS to achieve it? Looking forward to your reply! Regards, Wei On Sep 30, 2020, at 10:29, Synge Todo <wistaria@phys.s.u-tokyo.ac.jp<mailto:wistaria@phys.s.u-tokyo.ac.jp>> wrote: Dear Wei, Indeed, <\cos\theta> is zero if there is no external magnetic field. If there is a non-zero magnetic field, 'Magnetization along Field' is the quantity you are looking for. Best, Synge On Sep 30, 2020, at 11:03, Wei Wang <wei.wang@jhu.edu<mailto:wei.wang@jhu.edu>> wrote: Dear Prof. Todo, Thank you for your reply! I have added these two lines into my code, and print the measurements out: set(['Magnetization^2', 'Binder Cumulant', 'Specific Heat', '|Magnetization|', 'Magnetization^4', '|Staggered Magnetization|', 'Staggered Magnetization^2', 'E.Magnetization^4’, 'E.Magnetization^2', 'Energy Density', 'Susceptibility', 'beta * Energy / sqrt(N)', 'Magnetization along Field', 'Magnetization^4 slope', 'Connected Susceptibility', 'Magnetization^2 slope', 'Binder Cumulant U2', 'Cluster size', 'Bond-type Energy', 'Energy', 'Bond-type Energy Density', 'Energy^2', '(beta * Energy)^2 / N', 'Binder Cumulant slope']) I don’t find an observable like the <\cos\theta>, or which of the measurements above can give me the directions of the magnetization. Please forgive me if this is a silly question, I am a 1st-year graduate student learning how to use ALPS. Thank you! Regards, Wei On Sep 30, 2020, at 09:45, Synge Todo <wistaria@phys.s.u-tokyo.ac.jp<mailto:wistaria@phys.s.u-tokyo.ac.jp>> wrote: Dear Wei, You can obtain a list of measurements by data = pyalps.loadMeasurements(pyalps.getResultFiles(prefix='data/parmXY')) measurements = { item.props['observable'] for item in pyalps.flatten(data) } Best, Synge On Sep 30, 2020, at 9:49, Wei Wang <wei.wang@jhu.edu<mailto:wei.wang@jhu.edu>> wrote: Hi, I am just new to ALPS, and I have a silly question about running MC simulations of XY model: Following the tutorials, I use python to run the simulations and change the model from “Ising” to “XY”, like: import pyalps parms = [ { 'LATTICE': "square lattice", 'T': 1, 'J': 1, 'THERMALIZATION': 10000, 'SWEEPS': 400000, 'UPDATE': "cluster", 'MODEL': "XY", 'L': 8 } ] input_file = pyalps.writeInputFiles('data/parmXY', parms) pyalps.runApplication('spinmc', input_file, Tmin=5) result_files = pyalps.getResultFiles(prefix='data/parmXY') data = pyalps.loadMeasurements(result_files) how can I get some observables like <\cos\theta>, where \theta is the direction of the spin at each site? If such a quantity is not provided directly by ALPS, is there a possible method to get these quantities I want. I just get lost when I see the source code of ALPS. Thank you in advance! Best, Wei ---- Comp-phys-alps-users Mailing List for the ALPS Project https://nam02.safelinks.protection.outlook.com/?url=http%3A%2F%2Falps.comp-phys.org%2F&data=02%7C01%7Cwei.wang%40jhu.edu%7Ccdf695ebae424a066b9408d86f7d4d92%7C9fa4f438b1e6473b803f86f8aedf0dec%7C0%7C0%7C637381931260780833&sdata=CahGDtAMQP8YdGlNYLdQx2bvs17wlBFJ3PrUUkiTjpw%3D&reserved=0 List info: https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.phys.ethz.ch%2F%2Flistinfo%2Fcomp-phys-alps-users&data=02%7C01%7Cwei.wang%40jhu.edu%7Ccdf695ebae424a066b9408d86f7d4d92%7C9fa4f438b1e6473b803f86f8aedf0dec%7C0%7C0%7C637381931260780833&sdata=7R%2BRsE8itmC0IDpBHoi7dJL55guhKAURSBp%2FwJj0N6U%3D&reserved=0 Archive: https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.phys.ethz.ch%2F%2Fpipermail%2Fcomp-phys-alps-users&data=02%7C01%7Cwei.wang%40jhu.edu%7Ccdf695ebae424a066b9408d86f7d4d92%7C9fa4f438b1e6473b803f86f8aedf0dec%7C0%7C0%7C637381931260780833&sdata=VlXtNFGzK3EROdtawHftpHtIU2NqJGRN5mVeugvnSeE%3D&reserved=0 Unsubscribe by writing a mail to comp-phys-alps-users-leave@lists.phys.ethz.ch<mailto:comp-phys-alps-users-leave@lists.phys.ethz.ch>. ---- Comp-phys-alps-users Mailing List for the ALPS Project https://nam02.safelinks.protection.outlook.com/?url=http%3A%2F%2Falps.comp-phys.org%2F&data=02%7C01%7Cwei.wang%40jhu.edu%7Ccdf695ebae424a066b9408d86f7d4d92%7C9fa4f438b1e6473b803f86f8aedf0dec%7C0%7C0%7C637381931260780833&sdata=CahGDtAMQP8YdGlNYLdQx2bvs17wlBFJ3PrUUkiTjpw%3D&reserved=0 List info: https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.phys.ethz.ch%2F%2Flistinfo%2Fcomp-phys-alps-users&data=02%7C01%7Cwei.wang%40jhu.edu%7Ccdf695ebae424a066b9408d86f7d4d92%7C9fa4f438b1e6473b803f86f8aedf0dec%7C0%7C0%7C637381931260780833&sdata=7R%2BRsE8itmC0IDpBHoi7dJL55guhKAURSBp%2FwJj0N6U%3D&reserved=0 Archive: https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.phys.ethz.ch%2F%2Fpipermail%2Fcomp-phys-alps-users&data=02%7C01%7Cwei.wang%40jhu.edu%7Ccdf695ebae424a066b9408d86f7d4d92%7C9fa4f438b1e6473b803f86f8aedf0dec%7C0%7C0%7C637381931260780833&sdata=VlXtNFGzK3EROdtawHftpHtIU2NqJGRN5mVeugvnSeE%3D&reserved=0 Unsubscribe by writing a mail to comp-phys-alps-users-leave@lists.phys.ethz.ch<mailto:comp-phys-alps-users-leave@lists.phys.ethz.ch>. ---- Comp-phys-alps-users Mailing List for the ALPS Project https://nam02.safelinks.protection.outlook.com/?url=http%3A%2F%2Falps.comp-phys.org%2F&data=02%7C01%7Cwei.wang%40jhu.edu%7Ccdf695ebae424a066b9408d86f7d4d92%7C9fa4f438b1e6473b803f86f8aedf0dec%7C0%7C0%7C637381931260780833&sdata=CahGDtAMQP8YdGlNYLdQx2bvs17wlBFJ3PrUUkiTjpw%3D&reserved=0 List info: https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.phys.ethz.ch%2F%2Flistinfo%2Fcomp-phys-alps-users&data=02%7C01%7Cwei.wang%40jhu.edu%7Ccdf695ebae424a066b9408d86f7d4d92%7C9fa4f438b1e6473b803f86f8aedf0dec%7C0%7C0%7C637381931260780833&sdata=7R%2BRsE8itmC0IDpBHoi7dJL55guhKAURSBp%2FwJj0N6U%3D&reserved=0 Archive: https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.phys.ethz.ch%2F%2Fpipermail%2Fcomp-phys-alps-users&data=02%7C01%7Cwei.wang%40jhu.edu%7Ccdf695ebae424a066b9408d86f7d4d92%7C9fa4f438b1e6473b803f86f8aedf0dec%7C0%7C0%7C637381931260780833&sdata=VlXtNFGzK3EROdtawHftpHtIU2NqJGRN5mVeugvnSeE%3D&reserved=0 Unsubscribe by writing a mail to comp-phys-alps-users-leave@lists.phys.ethz.ch<mailto:comp-phys-alps-users-leave@lists.phys.ethz.ch>. ---- Comp-phys-alps-users Mailing List for the ALPS Project https://nam02.safelinks.protection.outlook.com/?url=http%3A%2F%2Falps.comp-phys.org%2F&data=02%7C01%7Cwei.wang%40jhu.edu%7Ccdf695ebae424a066b9408d86f7d4d92%7C9fa4f438b1e6473b803f86f8aedf0dec%7C0%7C0%7C637381931260790821&sdata=TYy12nLDq8PicZLkLHd%2Fl50K4CBof8yDXNKAA9xmq7o%3D&reserved=0 List info: https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.phys.ethz.ch%2F%2Flistinfo%2Fcomp-phys-alps-users&data=02%7C01%7Cwei.wang%40jhu.edu%7Ccdf695ebae424a066b9408d86f7d4d92%7C9fa4f438b1e6473b803f86f8aedf0dec%7C0%7C0%7C637381931260790821&sdata=9QJkYpTBsHAISM0b8aMCpvglDRFNIa9twzSkZft4kxE%3D&reserved=0 Archive: https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.phys.ethz.ch%2F%2Fpipermail%2Fcomp-phys-alps-users&data=02%7C01%7Cwei.wang%40jhu.edu%7Ccdf695ebae424a066b9408d86f7d4d92%7C9fa4f438b1e6473b803f86f8aedf0dec%7C0%7C0%7C637381931260790821&sdata=wguqkPJ49CAR1xFT2zEpBMeH51Jewv8j0LDEvbD3QVc%3D&reserved=0 Unsubscribe by writing a mail to comp-phys-alps-users-leave@lists.phys.ethz.ch<mailto:comp-phys-alps-users-leave@lists.phys.ethz.ch>. ---- Comp-phys-alps-users Mailing List for the ALPS Project https://nam02.safelinks.protection.outlook.com/?url=http%3A%2F%2Falps.comp-phys.org%2F&data=02%7C01%7Cwei.wang%40jhu.edu%7Ccdf695ebae424a066b9408d86f7d4d92%7C9fa4f438b1e6473b803f86f8aedf0dec%7C0%7C0%7C637381931260790821&sdata=TYy12nLDq8PicZLkLHd%2Fl50K4CBof8yDXNKAA9xmq7o%3D&reserved=0 List info: https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.phys.ethz.ch%2F%2Flistinfo%2Fcomp-phys-alps-users&data=02%7C01%7Cwei.wang%40jhu.edu%7Ccdf695ebae424a066b9408d86f7d4d92%7C9fa4f438b1e6473b803f86f8aedf0dec%7C0%7C0%7C637381931260790821&sdata=9QJkYpTBsHAISM0b8aMCpvglDRFNIa9twzSkZft4kxE%3D&reserved=0 Archive: https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.phys.ethz.ch%2F%2Fpipermail%2Fcomp-phys-alps-users&data=02%7C01%7Cwei.wang%40jhu.edu%7Ccdf695ebae424a066b9408d86f7d4d92%7C9fa4f438b1e6473b803f86f8aedf0dec%7C0%7C0%7C637381931260790821&sdata=wguqkPJ49CAR1xFT2zEpBMeH51Jewv8j0LDEvbD3QVc%3D&reserved=0 Unsubscribe by writing a mail to comp-phys-alps-users-leave@lists.phys.ethz.ch<mailto:comp-phys-alps-users-leave@lists.phys.ethz.ch>. ---- Comp-phys-alps-users Mailing List for the ALPS Project https://nam02.safelinks.protection.outlook.com/?url=http%3A%2F%2Falps.comp-phys.org%2F&data=02%7C01%7Cwei.wang%40jhu.edu%7Ccdf695ebae424a066b9408d86f7d4d92%7C9fa4f438b1e6473b803f86f8aedf0dec%7C0%7C0%7C637381931260790821&sdata=TYy12nLDq8PicZLkLHd%2Fl50K4CBof8yDXNKAA9xmq7o%3D&reserved=0 List info: https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.phys.ethz.ch%2F%2Flistinfo%2Fcomp-phys-alps-users&data=02%7C01%7Cwei.wang%40jhu.edu%7Ccdf695ebae424a066b9408d86f7d4d92%7C9fa4f438b1e6473b803f86f8aedf0dec%7C0%7C0%7C637381931260790821&sdata=9QJkYpTBsHAISM0b8aMCpvglDRFNIa9twzSkZft4kxE%3D&reserved=0 Archive: https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.phys.ethz.ch%2F%2Fpipermail%2Fcomp-phys-alps-users&data=02%7C01%7Cwei.wang%40jhu.edu%7Ccdf695ebae424a066b9408d86f7d4d92%7C9fa4f438b1e6473b803f86f8aedf0dec%7C0%7C0%7C637381931260790821&sdata=wguqkPJ49CAR1xFT2zEpBMeH51Jewv8j0LDEvbD3QVc%3D&reserved=0 Unsubscribe by writing a mail to comp-phys-alps-users-leave@lists.phys.ethz.ch<mailto:comp-phys-alps-users-leave@lists.phys.ethz.ch>.